Cordova在调用插件函数时遇到类型错误

时间:2017-03-14 16:05:42

标签: javascript android cordova phonegap-plugins cordova-plugins

我是Cordova的新手,我正在为sim信息开发一个测试应用程序。我正在使用 cordova-plugin-sim

我收到错误:

  

类型错误:无法调用方法getSimInfo

以防万一,我也使用了振动插件,它工作正常。

window.plugins.sim.getSimInfo(successCallback, errorCallback);

每当我使用window.plugins来调用插件的功能时,我都会收到 Type Error

我正在关注this link的教程 没有window.plugins的情况下使用的插件工作正常。

请帮助,谢谢!

代码如下:

document.addEventListener("deviceready",onDeviceReady,false); function onDeviceReady(){ try{ cordova.plugins.sim.getSimInfo(successCallback, errorCallback);} catch(ex){alert("error "+ex);} } function successCallback(result) { try{document.getElementById("simInfo").innerHTML=JSON.stringify(result);} catch(ex){alert("error "+ex);} } function errorCallback(error) { document.getElementById("simInfo").innerHTML=JSON.stringify(result); }

0 个答案:

没有答案
相关问题