vuex 参数绑定问题求解

组件中参数的定义像如下写的这样

https://img4.mukewang.com/5c24755a0001475910190786.jpg

其中sessions的定义能不能双向绑定呢, 我发现selectSession 方法执行的时候, sessions并没有改变,是不是哪里没有写对呢。

精慕HU
浏览 481回答 1
1回答

www说

vuex&nbsp;官方文档不是这么绑定数据的哦,数据监听放在&nbsp;computed里面,而不是直接放在&nbsp;data&nbsp;的方法里面,而且&nbsp;vuex&nbsp;对表单的双向处理是这样子的。//来自 vuex 官方例子<input v-model="message">// jscomputed: {&nbsp; message: {&nbsp; &nbsp; get () {&nbsp; &nbsp; &nbsp; return this.$store.state.obj.message&nbsp; &nbsp; },&nbsp; &nbsp; set (value) {&nbsp; &nbsp; &nbsp; this.$store.commit('updateMessage', value)&nbsp; &nbsp; }&nbsp; }}
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript