使用PhoneGap检查插件是否存在

时间:2012-02-09 04:27:49

标签: ios cordova phonegap-plugins

如果我的插件存在,我可以通过phoneGap.js检查吗?我希望我的应用程序具有条件逻辑,因此如果它不存在,它不会使用我的插件内容。

2 个答案:

答案 0 :(得分:2)

if (typeof window.plugins.myplugin !== 'undefined'){
   // plugin is available
}

答案 1 :(得分:1)

查看window.PhoneGap.resources对象:

  

window.PhoneGap.resources

Object
•  accelerometer: true
•  app: true
•  base: true
•  battery: true
•  camera: true
•  capture: true
•  compass: true
•  contact: true
•  crypto: true
•  device: true
•  file: true
•  filetransfer: true
•  geolocation: true
•  media: true
•  network: true
•  notification: true
•  position: true
•  storage: true
•  __proto__: Object
相关问题