M
M
Michael2020-06-23 10:19:42
Vue.js
Michael, 2020-06-23 10:19:42

Why is there no warning when changing the vuex state to bypass mutations?

Greetings.
The documentation clearly states:

You cannot directly change the state of a vault. The only way to make changes is to explicitly invoke the mutation.

But when I try the following:
store.js
export default new Vuex.Store({
  state: {
    tryvalue1: 'tryvalue1'
  },

mycomponent.vue
<template>
{{$store.state.tryvalue1}}
</template>
export default {
  methods: {
     changeTryvalue1(){
            this.$store.state.tryvalue1 += '-newvalue';
        }

I look that everything is working, no warnings/errors in the console.
Do you think it was supposed to be, just leave it to the developers, on the belief that they will never do this?

p.s. I'm using modern Vue.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-06-23
@Nolan81

strict mode

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question