# 数据临时存储 this.setStorage(key,value)
用于临时保存数据,将数据写入本地缓存
| 参数名 | 类型 | 必填 | 说明|
| --- | --- |--- | --- |
| key | string | 是 | 本地缓存中的指定的 key |
| value | all | 是 | key 对应的内容 |
示例
```
async mounted() {
let myData ={
name : '小明'
}
//同步存储
this.setStorage('myData',myData)
}
```
# 循环数据存储 this.setAllStorage(key,value)
在脚本爬取数据的时候将数据循环写入同一个arr中,此方法防止数据被顶掉
| 参数名 | 类型 | 必填 | 说明|
| --- | --- |--- | --- |
| key | string | 是 | 本地缓存中的指定的 key |
| value | all | 是 | key 对应的内容 |
示例
```
async mounted() {
let myData ={
name : '小明'
}
//同步存储
this.setAllStorage('myData',myData)
this.setAllStorage('myData',myData)
//当前‘myData’中存放数据为
/*
[
{
"name": "小明"
},
{
"name": "小明"
}
]
*/
}
```