How can I send data from parent to child component by vuex store in vue component?

前端 未结 2 1399
醉酒成梦
醉酒成梦 2020-12-22 13:22

My parent component like this :




        
2条回答
  •  星月不相逢
    2020-12-22 14:17

    Child's mounted hook is executed before parent's mounted hook. ( why? See this link)

    console.log(this.getCategory) happens before this.updateCategory(this.category).

    Therefore, you get null in the console.

    If you put console.log(this.getCategory) in updated hook, you would be getting the right value in the console later on.

提交回复
热议问题