Pinia使用方法与数据持久化学习
发布时间
阅读量:
阅读量
1、采用API接口形式的选项
import { defineStore } from 'pinia'
const useCountStore = defineStore('count', {
state: () => {
return {
count: 0,
}
},
// 同method支持异步
actions: {
add(num: number) {
this.count += num;
},
sub(num: number) {
this.count -= num;
},
addSync(time: number) {
setTimeout(() => {
this.count++;
}, time);
},
subSync(time: number) {
setTimeout(() => {
this.coun
全部评论 (0)
还没有任何评论哟~
