0
有人能解釋一下如何添加一個插件嗎?在Cordova 2.6上安裝Cordova插件
我加入了M和H文件Plugins目錄
然後在config.xml中添加一行:
<plugin name="DeviceDetails" value="DeviceDetails" />
,並列入我的HTML js文件
我現在如何真正使用這個插件?我怎麼知道它的工作原理?
我目前正在做的:(CoffeeScript的)
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":"[email protected]:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/media/js/index.js:24\[email protected]:///var/mobile/Applications/31C9E766-02DF-4C7E-8B32-9588F394F427/Flight.app/www/cordova-2.6.0.js:683\[email protected]:///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);