Vuex $store properties not reactive when using computed property

后端 未结 6 510
孤街浪徒
孤街浪徒 2020-12-29 23:03

I have a Vuex store, which I\'m injecting into my instance:

import store from \'../store\';

const mainNav = new Vue({
  el: \'#main-nav\',
  store,
  compon         


        
6条回答
  •  旧时难觅i
    2020-12-29 23:26

    When adding new properties to an Object from your Vuex store, you should either use

    Vue.set(obj, 'newProp', 123)
    

    or replace that Object with a fresh one

    state.obj = { ...state.obj, newProp: 123 }
    

    From Vuex docs

提交回复
热议问题