我写了一个vuex插件,如果一个特定的商店状态已更改,它可使多个商店刷新。一切工作正常,但我只想找出是否有一种方法来获取Store._actions的类型定义。您会在我的代码中看到我被迫使用任何代码。 RootState是包含我所有vuex存储模块的对象
const OnShopChangePlugin = (store: Store<RootState>) => {
store.watch(
state => state.shops.activeShopToken,
(val, oldVal) => {
// Don't do anything on init state
if (!oldVal) return;
for (let state in store.state) {
const action = `${state}/refresh`;
// If the store does not have an refresh action ignore
if ((store as any)._actions[action]) store.dispatch(`${state}/refresh`);
}
}
);
};