跳至内容

API 文档文档


API 文档 / pinia / acceptHMRUpdate

函数: acceptHMRUpdate()

acceptHMRUpdate<Id, S, G, A>(initialUseStore, hot): (newModule) => any

在 Vite 应用程序中,创建一个用于传递给 import.meta.hot接受函数。

类型参数

Id extends string = string

S extends StateTree = StateTree

G extends _GettersTree<S> = _GettersTree<S>

A = _ActionsTree

参数

initialUseStore: StoreDefinition<Id, S, G, A>

defineStore 的返回值,用于热更新

hot: any

import.meta.hot

返回值

函数

参数

newModule: any

返回值

any

示例

js
const useUser = defineStore(...)
if (import.meta.hot) {
  import.meta.hot.accept(acceptHMRUpdate(useUser, import.meta.hot))
}