错误如下
exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack ->
at useStore
解决办法
1.main.ts 中要 return { Pinia }
2.vue 文件中使用, usexxxStore() 要在 setup 之后调用
3.ts 文件中使用, usexxxStore() 放在函数内部调用,不要在 ts 文件顶部 import 之后就调用,这样会报错
解决办法第3点
例如你之前是这样写
import useTeacherStore from "@/store/useTeacherStore";
const teacherStore = useTeacherStore()
function action() {
return teacherStore
}
改为
import useTeacherStore from "@/store/useTeacherStore";
function action() {
const teacherStore = useTeacherStore()
return teacherStore
}