尝试从build.phonegap.com/plugins/414添加模块。
但是在将<gap:plugin name="com.badrit.macaddress" version="0.1.0" />
添加到config.xml和try { window.MacAddress.getMacAddress(function(macAddress) {alert(macAddress);},function(fail) {alert(fail);}); } catch {...
添加到index.html之后,我收到了错误“找不到类”
帮我
index.html
<!DOCTYPE html>
<html>
<head>
<title>navigator.network.connection.type Example</title>
<script src="cordova.js"></script>
<script type="text/javascript" charset="utf-8">
// Wait for PhoneGap to load
//
document.addEventListener("deviceready", onDeviceReady, false);
// PhoneGap is loaded and it is now safe to make calls PhoneGap methods
//
function onDeviceReady() {
checkConnection();
}
function checkConnection() {
alert('all ok');
try{
window.MacAddress.getMacAddress(
function(macAddress) {alert(macAddress);},function(fail) {alert(fail);}
);
} catch(e) {
alert(e.name)
} finally {
alert("finished")
}
}
</script>
</head>
<body>
<p></p>
</body>
</html>
config.xml
<?xml version="1.0" encoding="UTF-8" ?>
<widget xmlns = "http://www.w3.org/ns/widgets"
xmlns:gap = "http://phonegap.com/ns/1.0"
id = ""
versionCode = "10"
version = "1.0.0" >
<preference name="phonegap-version" value="3.3.0" />
<!-- versionCode is optional and Android only -->
<name>PhoneGap Example</name>
<description>
An example for phonegap build docs.
</description>
<author href="https://build.phonegap.com" email="[email protected]">
Hardeep Shoker
</author>
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.network-information" version="0.2.7" />
<gap:plugin name="com.badrit.macaddress" version="0.1.0" />
<gap:platform name="ios" />
<gap:platform name="android" />
</widget>
最佳答案
在index.html中,包含插件的脚本,如下所示:
<script type="text/javascript" src="MacAddress.js"></script>