Javascript phonegap index.js文件为什么app.receivedEvent不是this.receivedEvent
有谁能告诉我为什么在下面的代码中使用了app.receivedEvent('devicerady'),而不是Javascript phonegap index.js文件为什么app.receivedEvent不是this.receivedEvent,javascript,phonegap,Javascript,Phonegap,有谁能告诉我为什么在下面的代码中使用了app.receivedEvent('devicerady'),而不是这个.receivedEvent('devicerady') 注释实际上解释了在上使用app的原因: // The scope of 'this' is the event. In order to call the 'receivedEvent' // function, we must explicitly call 'app.receivedEvent(...);' 基本上,事件
这个.receivedEvent('devicerady')
注释实际上解释了在
上使用app
的原因:
// The scope of 'this' is the event. In order to call the 'receivedEvent'
// function, we must explicitly call 'app.receivedEvent(...);'
基本上,事件处理程序将使用自己的this
上下文调用事件回调(其中this
将是事件对象)
方法receivedEvent
在app中定义,而不是this
(设置为事件回调函数中的事件对象)。要调用receivedEventil
,在本例中,您可以将其作为包含对象app
的方法调用:
app.receivedEvent(...);
定义明确的。。。谢谢@Pineda
app.receivedEvent(...);