Vue 不同路由对应同一页面 监测路由变化更改数据 阿星小栈

 

   watch: {
        orgTreeShow(val){
            if(val){
                this.employeesShow = false;
            }else{
                this.loadEmployees()
            }
        }
    },
    beforeUpdate: function(){
        console.log('beforethis.$route',this.$route);
        if(this.$route.fullPath === '/company-manage/dept-frame' || this.$route.fullPath === '/theatre-manage/dept-frame'){
            this.orgTreeShow = true
        }else{
            this.orgTreeShow = false;
        }
    },
    created () {
        console.log('this.$route',this.$route);
        this.orgTreeShow = false;
        if(this.$route.fullPath === '/company-manage/dept-frame' || this.$route.fullPath === '/theatre-manage/dept-frame'){
            this.orgTreeShow = true
        }
        if(this.orgTreeShow){
            this.loadDeptsTree()
        }else{
            this.loadEmployees()
        }
    },

 

posted @ 2018-02-28 15:38  阿星小栈  阅读(173)  评论(0编辑  收藏  举报