Cordova插件错误:“未捕获的模块...已定义" [英] Cordova plugin error: "Uncaught module ... already defined"
问题描述
我遇到以下错误,我的自定义插件未启动.
I was getting the following error and my custom plugin wasn't starting.
未定义的模块com.example.example-plugin已定义"
为什么我的模块两次定义了?
Why is my module getting defined twice?
推荐答案
发生此错误是因为我将粘贴的代码从生成的"example-plugin.js"复制粘贴回原始插件文件中.
This error occurred because I copy-pasted code from the generated 'example-plugin.js' back into the original plugin file.
当我再次添加插件时,生成的代码然后被包装两次,如下所示:
When I added the plugin again, the generated code then got wrapped twice like this:
cordova.define("com.example.example-plugin",function(需要,导出,模块){cordova.define("com.example.example-plugin",function(需要,导出,模块)){var exec = require('cordova/exec');
从原始的example-plugin.js文件中删除生成的位,即可解决此问题.
Removing the generated bits from the original example-plugin.js file fixed this.
这篇关于Cordova插件错误:“未捕获的模块...已定义"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!