vue3监听store里的值
监听store中的state
·
监听state里的值变化
import { userStore } from "@store/user";
const user = userStore();
user.$subscribe((mutation: any, state: any) => {
if (state.hospCode) {
hospCode.value = state.hospCode
// 刷新列表
handleRefresh();
}
});
store中的state
// store/user.ts
import { defineStore } from "pinia";
import Pinia from "./index";
export const userStore = defineStore("user", {
state: () => ({
hospCode:''
}),
});
更多推荐
已为社区贡献1条内容
所有评论(0)