Cordova插件错误:"未捕获的模块......已定义"

aki*_*irs 11 cordova cordova-plugins

我收到以下错误,我的自定义插件没有启动.

"Uncaught module com.example.example-plugin already defined"

为什么我的模块定义了两次?

aki*_*irs 19

发生此错误是因为我将生成的'example-plugin.js'中的代码复制粘贴回原始插件文件.

当我再次添加插件时,生成的代码然后被包装两次,如下所示:

cordova.define("com.example.example-plugin", function(require, exports, module) { cordova.define("com.example.example-plugin", function(require, exports, module) { var exec = require('cordova/exec');

从原始example-plugin.js文件中删除生成的位修复了这个问题.


Nom*_*man 5

只是为了扩展 akiraspeirs 的答案。'example-plugin.js' 文件位于 Assets/www/plugins/example-plugin/example-plugin.js 下的 Android 文件夹中