标签: vue.js vuex
<input v-model="title" type="text"/>
const state = { title: 'default title' } const getters = { title: state => state.title } const mutations = { setTitle: (state, payload) => (state.title = payload.title) }
答案 0 :(得分:0)
If I change the text in the input, will the title be changed automatically?
否。您需要调用一些action,这将调用某些mutation并更新vuex的状态。
看看docs。
顺便说一句,您的获取器将始终返回undefined,因为在您的状态下没有称为count的字段。
undefined
应该是:
const getters = { title: state => state.title }