# 设置缓存
# setStorage
- 示例代码:
<template>
<div class="wrapper">
<text @click="cacheHandler">setStorage: 设置缓存</text>
</div>
</template>
<script>
export default {
data:()=> ({
name: 'setStorage',
}),
methods: {
cacheHandler() {
//设置缓存
this
.$storage
.setStorage('name','dolphinWeex')
.then(res => {
// {data: undefined, result: 'success'}
console.log('setStorage-res', res)
})
.catch(err => {
console.log('setStorage-err', err)
})
}
}
}
</script>
<style scoped>
.wrapper{
background-color: #ffffff;
}
</style>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 参数
- 参数详情:
Params | Type | Required | default | Value |
---|---|---|---|---|
key | String | Y | - | 缓存key值 |
value | any | Y | - | 缓存的值 |
set_time | Boolean | N | false | 时间戳 |
duration | Number | N | 0 | 有效时间 |
← 介绍 GetStorage 读取缓存 →