bug未解之谜

发布时间 2023-11-22 17:42:19作者: 菜鸟de博客
import { defineStore } from 'pinia'
import { ref } from 'vue'
export const empStore = defineStore(
  'big-stustore',
  () => {
    // 声明数据 state - count
    const empId = ref(100)
    // 声明操作数据的方法 action (普通函数)
    // const addCount = () => count.value++
    // const subCount = () => count.value--

    // 声明数据 state - msg
    const msg = ref('hello pinia')
    return {
      empId,
      msg
    }
  },
  {
    persist: true // 开启当前模块的持久化
    // persist: {
    //   key: 'hm-counter', // 修改本地存储的唯一标识
    //   paths: ['count'] // 存储的是哪些数据
    // }
  }
)
 
这次没问题了,以前常量刷新会丢失,函数无法访问,我还是不知道以前错哪里了