Vuex $store properties not reactive when using computed property

后端 未结 6 507
孤街浪徒
孤街浪徒 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

    Actually, you need to use Vue.set() function to make the new property reactive.

    changeType () {
       Vue.set(this.$store.state.nav, 'type', 'wide');
    }
    

    See this codepen: https://codepen.io/DedicatedManager/pen/JZgpaa

    I did a whole screen capture video on this subject: youtu.be/8GHczab2Lbs

提交回复
热议问题