2012-11-09 304 views
0

我正在使用cordova 2.1.0,並且正在嘗試向狀態欄添加通知。未捕獲TypeError:無法讀取屬性'statusBarNotification'的未定義

我會包括相關的Java文件和JS腳本到項目,並在

<plugin name="StatusBarNotification" value="com.phonegap.plugins.statusBarNotification.StatusBarNotification"/> 

在我的HTML代碼,我添加了以下線路中的config.xml中添加以下行我head標籤

<script src="cordova-2.1.0.js"/> 
<script src="statusbarnotification.js"/> 

,並在內容DIV頁面的底部,我添加了下面的腳本

<script> 
window.plugins.statusBarNotification.notify("Message Header", "Message details"); 
</script> 

但是,當我在模擬器中運行它爲Android 4.0,我打的錯誤:

Uncaught TypeError: Cannot read property 'statusBarNotification' of undefined

任何人有之前遇到這個問題?

回答

0

好吧,我的壞,這是一個虛驚。我將腳本文件放入js文件夾中,而不是放在與cordova js文件相同的文件夾中。在將腳本src路徑重命名爲正確的腳本之後,它現在正在工作。不能相信我花了幾個小時在這!

相關問題