<input v-model="getVal" />
computed: {
getVal: {
get() {
// 这里也是用了Vuex里的 modules 大家可以当成普通的变量来看
return this.$store.state.Root.value
},
set(newVal) {
this.$store.commit('handleVal', newVal)
}
}
}
复制代码
// store.js
mutations: {
handleVal(state, payload) {
state.value = payload
}
}
复制代码
详细地址