我正在尝试将 macaddress 插件添加到我的项目中。但我得到的是来自日志聊天的“无法运行构造函数:TypeError:Object # has no method 'addPlugin' at file:///android_asset/www/javascripts/cordova-2.0.0.js:297”。任何人都可以知道我该如何处理它以使我的插件工作。我正在使用来自https://github.com/phonegap/phonegap-plugins/tree/master/Android/MacAddress的插件。在我的 application.js 文件中,我写了
function onLoad() {
console.log('Init reached');
document.addEventListener('deviceready', onDeviceReady, false);
}
function onDeviceReady() {
console.log('Starting up...');
// navigator.app.overrideBackbutton(true);
document.addEventListener("backbutton", onBackKeyDown, false);
}
function getMacAddress(){
/*get macaddress*/
var networkInterface = {};
// Get network interface
networkInterface = window.plugins.macaddress.getMacAddress();
console.log(networkInterface.mac);
$("#wifi_mac_address").text(networkInterface.mac);
}
在 index.html 文件中,我写了
<!DOCTYPE html>
<html>
<head>
...
<script type="text/javascript" charset="utf-8" src="javascripts/cordova-2.0.0.js"></script>
<script type="text/javascript" charset="utf-8" src="javascripts/application.js"></script>
<script type="text/javascript" charset="utf-8" src="javascripts/jquery/jquery.mobile-1.1.1.js"></script>
<script type="text/javascript" charset="utf-8" src="javascripts/MacAddress.js"></script>
</head>
<body onload="onLoad()">
...
<li data-theme="c">
WiFi mac address:
<span id="wifi_mac_address">
123
</span>
</li>
...
</body>
</html>
我开始 phonegap 和 Jquery mobile 仅 3 周。如果你知道,请给我一些建议来解决它。提前非常感谢。