vue的监听watch报错,这个从来没遇到过

vue.esm.js:579 [Vue warn]: Error in callback for watcher "level": "TypeError: Cannot convert undefined or null to object"

found in

图片描述

阅读 10.9k
2 个回答

重点是看日志,没遇到过没关系,日志说:在side.vue文件里边的watch函数有问题,打个断点看看就行啦

加判断,错在第一次没有oldVal

    level:{
        handler: function (val, oldVal) { 
            if(oldVal!=val&&this.haveResh){
                this.routerTo(this.level.place,null)
            }
            this.haveResh=true;
            // alert(this.level.place);
        },
        deep: true               
    }
推荐问题