1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
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; } }, }
`
|