lol*_*irl 3 javascript android phonegap-plugins cordova phonegap-build
我有一个简单的 Phonegap Build 应用程序,我试图在其中使用设备插件。我已经通过命令行安装了插件并确认它已安装。
我在 onDeviceReady 中有以下 js:
alert(device.platform); 和 alert(device.model);
我得到没有警报的白屏。
Chrome 开发工具远程检查控制台说:未捕获的 ReferenceError:平台未定义
插件未被识别。
使用此推荐添加此cordova插件:
cordova plugin add cordova-plugin-device
Run Code Online (Sandbox Code Playgroud)
Try this
<html>
<head>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript">
//add event listener
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady() {
console.log(device); // device object
console.log(device.name); // Gives the name of device.
console.log(device.uuid ); // Gives the UUID.
}
</script>
</head>
<body>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)