我想做两个复选框,从store.js
中获取值,并通过表单将其发送到后端:
<label>Notify me
<input type="checkbox" v-model="notification" value="notification" />
</label>
<label>Email me
<input type="checkbox" v-model="email" value="email" />
</label>
我将这些值作为计算(computed)属性:
computed: {
BASE_URL () {
return this.$store.state.BASE_URL;
},
notification () {
return this.$store.state.notification;
},
email () {
return this.$store.state.email;
}
}
问题是,选中复选框不会更改存储中的值,此外,我在控制台中收到以下警告:
vue.esm.js?65d7:479 [Vue warn]: Computed property "notification" was assigned to but it has no setter.
我知道可以在计算(computed)属性中定义setter,在vue中定义为described.js文档,但我不知道当有多个值要设置时如何设置,比如在我的特殊情况下.
谢谢你帮我解决这个问题.