reportComplaints.js: Uncaught TypeError: Cannot read property 'message' of undefined
阿新 • • 發佈:2018-06-07
port 定義 錯誤 prope urn UNC mil turn peer
vonic 中遇到這麽個問題, 一直提示我未定義, 可是明明有定義
var tab={ message:{ number:‘‘, title:‘‘ } }
var id= { template: ‘#id‘, data: function(){ return tab; }, created: function () { //感覺問題就是這
var self = this; }, methods: { showComplaintsDetail:function(item){ var self = this; self.tab.message= item; //這樣寫就會報那個錯誤
}
}
}
後來發現可能是var self = this; 的問題, 結果去掉後就正常了,或者把tab去掉也可以恢復正常, 感覺就是self獲取的this不一樣, 有些self中包含tab, 有些包含的是tab中的屬性,
這裏先簡單記一下, 有機會在深入了解
reportComplaints.js: Uncaught TypeError: Cannot read property 'message' of undefined