标签:date dia cti uil arch store methods var word
2018-10-15
本文记录一下项目中的watch的用法
12345678910111213141516171819202122232425262728
mounted() { this.$nextTick(() => { //初始化读取vuex中的全局参数 if (this.$store.state.user.projectCode) { this.projectCode = this.$store.state.user.projectCode; } }); }, computed:{//配合watch监听使用 selectProject() { return this.$store.state.user.projectCode; } }, watch:{ selectProject: ‘selectProject_‘, deep: true, //深度监听 immediate: true//以当前的初始值执行handler的函数 }, methods: { //监听选择项目的值 selectProject_(newVal, oldVal) { if (newVal) { this.projectCode = newVal; } }, }`
vue watch监听全局的projectCode
原文地址:https://www.cnblogs.com/lianggl/p/14536038.html