Vue.js 要在Vuejs中的父组件之后运行的子组件上使用哪个生命周期挂钩?

Vue.js 要在Vuejs中的父组件之后运行的子组件上使用哪个生命周期挂钩?,vue.js,vue-component,vuex,Vue.js,Vue Component,Vuex,在父级上,我运行以下命令: mounted(){ this.$store.dispatch('fetchNotesAction') }, components: { ChildComponent } 这样,Vuex存储区就充满了数据 因此,我假设,当子组件运行时,存储区已经满了 在ChildComponent中,我正在尝试这个 mounted(){ console.log(this.$store.getters.getNotes) }, 如果我在父级中记录了完全

在父级上,我运行以下命令:

  mounted(){
    this.$store.dispatch('fetchNotesAction')
  },
components: { ChildComponent }
这样,Vuex存储区就充满了数据

因此,我假设,当子组件运行时,存储区已经满了

ChildComponent
中,我正在尝试这个

mounted(){
    console.log(this.$store.getters.getNotes) 
  },
如果我在父级中记录了完全相同的代码,则在
分派之后,它将显示数据。因此,这些行后面的代码(连接)工作正常,只是我假设不需要再次运行fetch(从
fetchNotesAction
)是否正确


我尝试了
创建
而不是
挂载
,同样的

最佳做法是使用一个返回状态getter的计算属性,然后使用watch属性观察子组件中的更改:

computed:{
  notes(){
   return  this.$store.getters.getNotes;
   }
},
watch:{
  notes(newval,oldVal)'
    console.log(newval) 
  }
}