vueのコンポーネント内監視$storeで定義された変数の変化について詳しく説明します。
//1.計算属性を用いて$storeの値を取得する
computed: {
listenstage() {
return this.$store.state.iShaveMsg;
}
},
//2.ウオッチで定義計算属性の取得値の変化をチェックする
watch:{
listenstage: function(ov,nv){
console.log('watch start……');
if(this.$store.state.iShaveMsg){
//
}
}
console.log('watch stop……');
}
},
以上のこのvueのコンポーネントの中で監視します。storeで定義された変数の変化について詳しく解説すると、小編集が皆さんに教えてくれたすべての内容です。参考にしてほしいです。どうぞよろしくお願いします。