美文网首页
自定义cordova插件

自定义cordova插件

作者: 哈哈111 | 来源:发表于2017-04-27 15:32 被阅读0次
  1. cordova create Demo

  2. cd Demo

  3. cordova platform add ios android

  4. npm install -g plugman

  5. cordova plugin add cordova-plugin-device

  6. cordova plugin rm cordova-plugin-device

  7. plugman create --name MyInfo --plugin_id info --plugin_version 1.0.0

  8. cd MyInfo

  9. plugman platform add --platform_name android

  10. 修改(bug)
    source-file src=”src/Android/MyMath.java” target-dir=”src/SimpleMath/MyMath”
    为:
    source-file src=”src/android/MyMath.java” target-dir=”src/SimpleMath”

  11. 调用顺序

js 调用 –> cordova.plugins.MyMath.plus(arg0, success, error)
cordova的接口exec –> exec(success, error, “MyMath”, “Plus”, arg0);
调用底层实现各自平台(ios或者Android)下的类MyMath。

12.cordova plugin add ../MyInfo
13.将Demo-->platforms-->android工程导入到Android studio中
14.如果在Demo工程-->www目录下修改了代码,使用cordova prepare来同步到Android原生工程中
15.报这个错时Refused to execute inline script because it violates the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".
将这一段注释掉<meta http-equiv="Content-Security-Policy" content="default-src 'self' data: gap: https://ssl.gstatic.com 'unsafe-eval'; style-src 'self' 'unsafe-inline'; media-src *; img-src 'self' data: content:;">

相关文章

网友评论

      本文标题:自定义cordova插件

      本文链接:https://www.haomeiwen.com/subject/pozgzttx.html