[英]phonegap - device is not defined
當我啟動該應用程序時,它將打開運行以下代碼的index.html
:
<script type="text/javascript">
$(document).ready(function(){
document.addEventListener('deviceready', app.onDeviceReady, false);
});
</script>
在app.js
var app = {
onDeviceReady: function() {
alert(device.model);
window.location.replace('pages/home.html');
},
};
它將警告device.model
並重定向到pages/home.html
。
在pages/home.html
,
<script type="text/javascript">
$(document).ready(function(){
alert(device.model);
});
</script>
在第一個警報中,我正確地獲得了設備模型,但是在重定向到pages/home.html
,我收到了錯誤消息Uncaught ReferenceError: device is not defined
設備由phonegap / cordova插件提供,但未在您的pages / home.html中加載。 此外,設備應在設備就緒而非文檔就緒事件中可用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.