因为getItem 获取的内容可能为null 也可能有值 解决1 JSON.parse(localStorage.getItem('key') || '[]') 解决2 类型没有匹配好的 加 as String 定义一下