I have a Vue app with an input element bound to a like this:
(我有一个Vue应用,其输入元素绑定到一个这样的:)
<template>
<input v-model="this.$store.state.myvalue"/>
</template>
and VueX store/index.js
:
(和VueX store/index.js
:)
import Vue from "vue";
import Vuex from "vuex";
Vue.use(Vuex);
export default new Vuex.Store({
state: {
myvalue: null
},
mutations: {},
actions: {},
modules: {}
});
When I modify myvalue
with Vue devtools, the input's value changes too, but when I change the value in the input field, the state variable does not change.
(当我使用Vue devtools修改myvalue
时,输入值也会更改,但是当我在输入字段中更改值时,状态变量不会更改。)
What am I doing wrong?(我究竟做错了什么?)
I'm new to VueX.(我是VueX的新手。)
ask by retnikt translate from so
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…