【发布时间】:2022-08-17 05:09:12
【问题描述】:
import { defineStore, acceptHMRUpdate } from \'pinia\';
import { v4 as uuidv4 } from \'uuid\';
export const useStoreNotes = defineStore(\'storeNotes\', {
state: () => ({
notes: [
{
id: \'8d3ce756-ef35-4e68-80bd-fb97e03a831b\',
content: \'Learn React\',
},
{
id: \'11860d36-cb57-455e-9b9c-083ef5762f7e\',
content: \'Learn Java\',
},
],
}),
})
if (import.meta.hot) {
import.meta.hot.accept(acceptHMRUpdate(useStoreNotes, import.meta.hot));
}
嘿,我正在尝试在 Pinia (Vuex5) 中使用 HMR(热模块更换)。我也在用Vite。我尝试使用 Pinia 官方文档中的 HOT 重载:https://pinia.vuejs.org/cookbook/hot-module-replacement.html
但是热重载不起作用。如果我在商店中更新某些内容,我必须刷新页面,并且我想在不刷新页面的情况下查看更改。
标签: vue.js vuejs3 store pinia vuex4