鍍金池/ 問答/HTML/ vue的監(jiān)聽watch報(bào)錯(cuò),這個(gè)從來沒遇到過

vue的監(jiān)聽watch報(bào)錯(cuò),這個(gè)從來沒遇到過

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

found in

圖片描述

回答
編輯回答
壞脾滊

加判斷,錯(cuò)在第一次沒有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               
    }
2017年3月11日 23:51
編輯回答
青裙

重點(diǎn)是看日志,沒遇到過沒關(guān)系,日志說:在side.vue文件里邊的watch函數(shù)有問題,打個(gè)斷點(diǎn)看看就行啦

2017年5月28日 17:41