有人可以解释如何添加插件吗?
我将 m 和 h 文件添加到 Plugins 目录
然后在 config.xml 中添加以下行:
<plugin name="DeviceDetails" value="DeviceDetails" />
并将js文件包含在我的html中
我现在如何实际使用这个插件?我怎么知道它有效?
我目前正在做:(咖啡脚本)
try
console.log DeviceDetails()
catch e
console.log e
并在 xCode 中出现此错误:
[LOG] {"line":24,"sourceURL":"file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/media/js/index.js","stack":"onDeviceReady@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/media/js/index.js:24\nfire@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/cordova-2.6.0.js:683\n@file:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/cordova-2.6.0.js:221\n[native code]"}
这是插件js文件:
;(function(cordova) {
function DeviceDetails() {}
DeviceDetails.prototype.getDetails = function(callback) {
cordova.exec(callback, callback, "DeviceDetails", "getDeviceDetails", [])
}
DeviceDetails.prototype.getUUID = function(callback) {
cordova.exec(callback, callback, "DeviceDetails", "getDeviceUUID", [])
}
if (!window.plugins) window.plugins = {}
window.plugins.deviceDetails = new DeviceDetails()
})(window.cordova || window.Cordova || window.PhoneGap);