watch监听vuex内部数据变化
生活随笔
收集整理的這篇文章主要介紹了
watch监听vuex内部数据变化
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
2019獨角獸企業重金招聘Python工程師標準>>>
//使用計算屬性連接vuex的變量,在用watch去監聽,變相的實現監聽vuex內部state變化 <template><div class="page2"><button @click="togglepage2">點擊切換</button></div> </template><script>export default {name: 'page2',data() {return {}},computed: {listenshowpage1() {return this.$store.state.showpage2;}},watch: {listenshowpage1: function(a, b) {console.log("修改前衛:" + a);console.log("修改后為:" + b);}},methods:{togglepage2:function(){this.$store.commit({type:"togglepage2"})}}} </script><!-- Add "scoped" attribute to limit CSS to this component only --> <style scoped></style> 暫無其他大變動轉載于:https://my.oschina.net/daladida/blog/2993500
總結
以上是生活随笔為你收集整理的watch监听vuex内部数据变化的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 酷狗音乐怎么取消别人的登录
- 下一篇: 考验信仰、财力的时候到了!丰田加价神车新