vite热重载后上下文是不是发生了变化? #419
Unanswered
qq790880208
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
具体表现为我在代码中使用了Symbol("test")作为store的key值,在热重载后使用useStore(Symbol("test"))获取store的实例失败,原因是热重载后的Symbol与之前的Symbol不一致。
`
// vuex store.ts
export const store = createStore({});
export const key: InjectionKey<Store> = Symbol("test");
// main.ts
import { key } from './store'
window.key = key; // 测试使用
const app = createApp(App).use(store, key).mount("#app");
//App.vue
import { key } from './store'
console.log(key === window.key) //page reload打印值为true, hot update后打印值为false
`
Beta Was this translation helpful? Give feedback.
All reactions