【发布时间】:2019-11-28 05:38:53
【问题描述】:
我目前正在使用 vue。商店正在更新我的数组,但不会更新我的字符串或布尔值。
我的代码是here:
我每秒提交一次字符串,但字符串没有显示在前端(vuex 开发工具显示状态正确,我的控制台日志没有)
我的商店如下所示:
const state: State = {
cars: [],
date: "false",
carsCounter: 0,
};
我的出口:
const getters = {
getCars(state: State) {
return state.cars;
},
getDate(state: State) {
return state.date;
},
getCarsCounter(state: State) {
return state.carsCounter;
}
};
const { read, commit, dispatch } = getStoreAccessors<State, State>("");
export const readCarsFromSse = read(getters.getCars);
export const readDate = read(getters.getDate);
export const readCarsCounter = read(getters.getCarsCounter);
我在日期组件中使用它,如下所示:
export default class DateVue extends Vue {
date = readDate(store);
cars = readCarsFromSse(store);
testString = readCarsCounter(store);
mounted() {
Timeloader.loadTime();
}
}
有谁知道为什么字符串没有更新,而数组却更新了?
谢谢
【问题讨论】:
-
read函数是什么? -
对不起:
const { read, commit, dispatch } = getStoreAccessors<State, State>("");
标签: javascript typescript vue.js vuex