基础库 2.12.2
/* index.js */
onShow: function () {
//启动通知监听
app.watchMessage.call(this); // 修改this指向
...
},
/* app.js */
async watchMessage() {
//var that = this
console.log(this); //打印出来的this还是app
…
}
apply/bind/call了解一下
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/apply
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/bind
https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Function/call