本文介绍了我们应该使用v-model来修改Vuex store吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我是 Vue 的初学者,我确实遇到了一个真正困扰我的问题.我想知道我们应该使用 v-model 指令来修改 vuex 存储吗?Vuex 说我们应该只通过突变修改 vuex 存储,但 v-model 使一切变得更容易和更短.(我问是因为我找不到明确的答案)

解决方案

https://vuex.vuejs.org/guide/forms.html

在严格模式下使用 Vuex 时,在属于 Vuex 的状态片段上使用 v-model 可能有点棘手.

Vuex 方式"处理它是绑定 的值并对输入或更改事件调用操作.

请务必查看简单的双向计算属性"该页面上的示例:

计算:{信息: {得到 () {返回 this.$store.state.obj.message},设定值) {this.$store.commit('updateMessage', value)}}}

Hello I am beginner in Vue and I do have a problem that's really bugging me.I am wondering should we use v-model directive to modify vuex store? Vuex says that we should modify vuex store only by mutations but v-model makes everything easier and shorter.(I am asking because i couldn't find clear answer)

解决方案

https://vuex.vuejs.org/guide/forms.html

Be sure to check out the simple "Two-way Computed Property" example on that page:

这篇关于我们应该使用v-model来修改Vuex store吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 06:31
查看更多