修改值
https://blog.csdn.net/qq_42543244/article/details/123407045
只修改一个值:直接修改
请注意,store 是一个用 reactive 包装的对象,这意味着不需要在 getters 后面写 .value。就像 setup 中的 props 一样,我们不能对它进行解构 https://pinia.vuejs.org/zh/core-concepts/#using-the-store
@/stores/app.ts
import { defineStore } from "pinia";
const initState = {
myState = 0;
err: {
msg: "",
show: false,
},
save2tau: false,
};
export const useAppStore = defineStore("app", {
state: () => initState,
actions: {
complexUpdate(x: number) {
//随便写的复杂逻辑
this.myState += this.myState + x;
if (this.save2tau) this.myState %= 5;
return "I
标签:const,pinia,appS,myState,useAppStore,vue3,拷贝
From: https://www.cnblogs.com/nolca/p/18146083