a'ゞ永香
a'ゞ永香Lv1
Pinia真的香啊!!刚把项目里的Vuex换成Pinia,写法清爽到哭 store直接defineStore(),不用写mutations了…异步逻辑扔actions里,状态自动响应式,连$subscribe都比以前顺滑…试了下在组件里useStore().count++,刷新页面居然还保留着(devtools真没白开)…谁懂啊,再也不想回Vuex的嵌套地狱了…

const useUserStore = defineStore('user', {
  state: () => ({ name: '', age: 0 }),
  actions: { fetchUser() { this.name = '张三'; this.age = 25; } }
})