uniapp数据存储、获取和删除
<template><view class="content"><button type="primary" @click="setStorage">存储数据</button><button type="primary" @click="getStorage">获取数据</button><button type="pri
·
<template>
<view class="content">
<button type="primary" @click="setStorage">存储数据</button>
<button type="primary" @click="getStorage">获取数据</button>
<button type="primary" @click="delStorage">删除数据</button>
</view>
</template>
<script>
export default {
methods: {
setStorage() {
uni.setStorage({
key: 'name',
data: 'uniapp',
success() {
console.log('存储数据')
}
})
},
getStorage() {
uni.getStorage({
key: 'name',
success(res) {
console.log('获取成功', res.data)
}
})
},
delStorage() {
uni.removeStorage({
key: 'name',
success() {
console.log('删除成功')
}
})
}
}
}
</script>
<style>
.content {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
</style>
更多推荐
已为社区贡献13条内容
所有评论(0)