2015-02-09 222 views
0

我想导入示例插件在科尔多瓦/离子测试,我现在试试这个如何使用插件在科尔多瓦/离子框架

$ cordova plugin add org.apache.cordova.device 

在我的index.html我用这个代码

var model = device.model; 
document.write(device.model); 

然后

cd myionicApp 
cordova emulate 

,但它不工作,谁能帮助我? 还安装科尔多瓦CLI和科尔多瓦Plugman和离子框架

回答

1

document.addEventListener("deviceready", success, error); 
function success(){ 
    var model = device.model; 
    document.write(device.model); 
}; 
function error(){ 

}; 

添加

var model = device.model; 
document.write(device.model); 

在你的情况下,它并没有因为工作在设备准备就绪之前不会调用插件。所以我们需要添加设备准备好的监听器。那么只有任何插件会被调用。

问候。

相关问题