vuex store doesn't update component

后端 未结 4 1444
别跟我提以往
别跟我提以往 2020-12-25 14:41

I\'m new to vue, so I\'m probably making a rookie error.

I have a root vue element - raptor.js:

const Component = {
el: \'#app\',
store,
data: {
             


        
4条回答
  •  心在旅途
    2020-12-25 15:13

    UPDATE

    Figured it out myself. Just had to replace the components data part with a computed method:

    data:

    data: {
      productList: store.state.productlist
    }
    

    and replace it with.

    computed: {
        productList () {
            return store.state.productlist;
        }
    },
    

提交回复
热议问题