一、问题详情
14:56:47.251 reportJSException >>>> exception function:createInstanceContext, exception:white screen cause create instanceContext failed,check js stack -> at useStore (app-service.js:5799:15) at (app-service.js:11334:23) at (app-service.js:120143:3)
二、解决
在使用Pinia的store的时候,注意初始化时机,特别是在js文件中使用,可以把初始化状态放到函数中,不要在js文件顶层做初始化状态
// 错误的示例
import { globalStore } from '@/store/global'
const globalInstance = globalStore()
export function test() {
// 使用globalInstance
}
// 正确的示例
import { globalStore } from '@/store/global'
export function test() {
const globalInstance = globalStore()
// 使用globalInstance
}
把项目里面所有的都要改掉