2
我在組件中使用商店值並嘗試更新它。當我單擊按鈕時,存儲值發生更改,但更改未反映在組件輸出中(即{{query}} )由於觀看地圖狀態不起作用
<template>
span {{query}}
button(@click='updateQuery')
</template>
<script>
export default {
computed: mapState('map', [
'query'
]),
methods: {
...mapMutations('map', [
'setStart'
]),
updateQuery() {
this.setStart(new Date());
}
}
}
</script>
店:
export default {
namespaced: true,
state: {
query: {},
start: null,
end: null
},
mutations: {
setQuery(state, value) { state.query = value },
setStart(state, value) {
state.start = value;
state.query.timestamp = state.query.timestamp ? state.query.timestamp : {};
state.query.timestamp.$gte = value;
},
setEnd(state, value) {
state.end = value;
state.query.timestamp = state.query.timestamp ? state.query.timestamp : {};
state.query.timestamp.$lte = value;
},
}
}
你在模板中使用某種渲染引擎嗎?也許這是造成這種影響?還是一次v? – phoet