problem with mutation in vuex #8838
Replies: 3 comments
-
See the vuex docs for help: |
Beta Was this translation helpful? Give feedback.
-
hi @pospi-cz |
Beta Was this translation helpful? Give feedback.
-
@pospi-cz I probably would have done it this way: <template>
<div v-for="(item, inx) in get_list" v-bind:key="inx">
<q-input :modelValue="item.value" :label="item.name" outlined dense @update:modelValue="val => get_list(val, inx)"/>
</div>
<div>
{{ get_list }}
</div>
</template>
<script>
import { defineComponent, ref } from "vue";
import { mapGetters, mapActions } from "vuex";
export default defineComponent({
name: "Test",
computed: {
get_list: {
get () {
return this.$store.test.state.list
},
set (value, index) {
this.$store.commit('test/update_Item', { value, index })
}
}
}
});
</script> and add the missing mutation const mutations = {
update_item (state, { value, index }) {
state.list[index] = value
}
} Note: untested... Edit: haha! Just noticed this is a mix of options and composition apis |
Beta Was this translation helpful? Give feedback.
-
Hi my problem is console message [[vuex] do not mutate vuex store state outside mutation handlers.] when edit inputs
Im very new in Vue so be kind :)
My code test.vue:
store-test.js :
My question is : how code actions and mutations ?
Beta Was this translation helpful? Give feedback.
All reactions