一、問(wèn)題詳情
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的時(shí)候,注意初始化時(shí)機(jī),特別是在js文件中使用,可以把初始化狀態(tài)放到函數(shù)中,不要在js文件頂層做初始化狀態(tài)
// 錯(cuò)誤的示例
import { globalStore } from '@/store/global'
const globalInstance = globalStore()
export function test() {
// 使用globalInstance
}
// 正確的示例
import { globalStore } from '@/store/global'
export function test() {
const globalInstance = globalStore()
// 使用globalInstance
}
把項(xiàng)目里面所有的都要改掉