Akryum / Akryum/vue-cli-plugin-ssr
Vuex strict mode always leads to "do not mutate vuex store state outside mutation handlers"
- Lingua principale
- JavaScript
- Stelle
- 441
- Fork
- 69
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
Strict mode: https://vuex.vuejs.org/guide/strict.html
When this is enabled, all mutations throw an error (stack trace below), *even when commited* through a mutation, as you should:
```html
set someVal
```
```js
export function createStore() {
return new Vuex.Store({
strict: true, // <----------
state() { return { someVal: false } },
mutations: {
setSomeVal(state) {
state.someVal = true;
}
},
actions: {}, modules: {}
})}
```
Clicking the button should not generate the error, but it does. I tested this with a clean vue project with nothing else added.
Is this expected behaviour or a bug? If the latter, do you still accept pull requests in case I can track it down?
Thanks!
```
VM547 chunk-vendors.js:8373 [Vue warn]:
Error in callback for watcher "function () { return this._data.$$state }":
"Error: [vuex] do not mutate vuex store state outside mutation handlers."
(found in )
warn @ VM547 chunk-vendors.js:8373
logError @ VM547 chunk-vendors.js:9636
globalHandleError @ VM547 chunk-vendors.js:9631
handleError @ VM547 chunk-vendors.js:9591
run @ VM547 chunk-vendors.js:12317
update @ VM547 chunk-vendors.js:12289
notify @ VM547 chunk-vendors.js:8484
reactiveSetter @ VM547 chunk-vendors.js:8809
reactiveSetter @ vue.runtime.esm.js:1050
setSomeVal @ index.js:16
wrappedMutationHandler @ vuex.esm.js:744
commitIterator @ vuex.esm.js:392
(anonymous) @ vuex.esm.js:391
_withCommit @ vuex.esm.js:526
commit @ vuex.esm.js:390
boundCommit @ vuex.esm.js:335
click @ Home.vue?012f:17
invokeWithErrorHandling @ vue.runtime.esm.js:1854
invoker @ vue.runtime.esm.js:2179
original._wrapper @ vue.runtime.esm.js:6917
VM547 chunk-vendors.js:9640 Error: [vuex] do not mutate vuex store state outside mutation handlers.
at assert (VM547 chunk-vendors.js:16303)
at Vue.store._vm.$watch.deep (VM547 chunk-vendors.js:17006)
at Watcher.run (VM547 chunk-vendors.js:12315)
at Watcher.update (VM547 chunk-vendors.js:12289)
at Dep.notify (VM547 chunk-vendors.js:8484)
at Object.reactiveSetter (VM547 chunk-vendors.js:8809)
at Object.reactiveSetter [as someVal] (VM547 chunk-vendors.js:8804)
at Store.setSomeVal (VM548 app.js:1950)
at wrappedMutationHandler (VM547 chunk-vendors.js:16957)
at commitIterator (VM547 chunk-vendors.js:16605)
```
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Valutazione
Questa issue non è ancora stata valutata.