简体   繁体   English

iOS Cordova 3.x:设备插件

[英]iOS Cordova 3.x: Device plugin

I am testing out the device plugin for a Cordova 3.3 project on iOS Simulator 6.0 7.0 我正在为iOS Simulator 6.0 7.0上的Cordova 3.3项目测试设备插件

So my steps: 所以我的步骤:

  1. npm install cordova NPM安装科尔多瓦
  2. cordova create MyFunkyApp 科尔多瓦创建MyFunkyApp
  3. cd MyFunkyApp cd MyFunkyApp
  4. cordova platform add ios 科尔多瓦平台添加ios
  5. cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git 科尔多瓦插件添加https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
  6. change index.html to 将index.html更改为

Device Properties Example 设备属性示例

 <script type="text/javascript" charset="utf-8" src="cordova.js"></script> <script type="text/javascript" charset="utf-8"> // Wait for device API libraries to load // document.addEventListener("deviceready", onDeviceReady, false); // device APIs are available // function onDeviceReady() { var element = document.getElementById('deviceProperties'); element.innerHTML = 'Device Name: ' + device.name + '<br />' + 'Device Cordova: ' + device.cordova + '<br />' + 'Device Platform: ' + device.platform + '<br />' + 'Device UUID: ' + device.uuid + '<br />' + 'Device Model: ' + device.model + '<br />' + 'Device Version: ' + device.version + '<br />'; } </script> </head> <body> <p id="deviceProperties">Loading device properties...</p> </body> </html> 

This script from cordova.apache.org Device API 该脚本来自cordova.apache.org设备API

But its not works. 但它不起作用。 Loading device properties... all the time on screen. 一直在屏幕上加载设备属性...。 What I do wrong ? 我做错了什么?

You need to command-line build your project first, as opposed to just building it with Xcode: 您需要先通过命令行构建项目,而不是仅使用Xcode进行构建:

cordova build ios

Then run it in the simulator - should work. 然后在模拟器中运行-应该可以。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM