cordova自定义组件在vue调用时报 Error: exec proxy not found for

hanlei233
  • 40

我开发的项目是 cordova + vue;
在自定义组件名为:commonBridge
组件内容代码:

var exec = require('cordova/exec');

exports.goToNative = function (arg0, success, error) {
    exec(success, error, 'commonBridge', 'goToNative', [arg0]);
};

cordova_plugins.js引入成功后的相关代码:

cordova.define('cordova/plugin_list', function(require, exports, module) {
module.exports = [
    {
        "file": "plugins/cordova-plugin-camera/www/CameraConstants.js",
        "id": "cordova-plugin-camera.Camera",
        "pluginId": "cordova-plugin-camera",
        "clobbers": [
            "Camera"
        ]
    },
    {
        "file": "plugins/cordova-plugin-camera/www/CameraPopoverOptions.js",
        "id": "cordova-plugin-camera.CameraPopoverOptions",
        "pluginId": "cordova-plugin-camera",
        "clobbers": [
            "CameraPopoverOptions"
        ]
    },
    {
        "file": "plugins/cordova-plugin-camera/www/Camera.js",
        "id": "cordova-plugin-camera.camera",
        "pluginId": "cordova-plugin-camera",
        "clobbers": [
            "navigator.camera"
        ]
    },
    {
        "file": "plugins/cordova-plugin-camera/src/browser/CameraProxy.js",
        "id": "cordova-plugin-camera.CameraProxy",
        "pluginId": "cordova-plugin-camera",
        "runs": true
    },
    {
        "file": "plugins/commonBridge_plugin/www/commonBridge.js",
        "id": "commonBridge_plugin.commonBridge",
        "pluginId": "commonBridge_plugin",
        "clobbers": [
            "cordova.plugins.commonBridge"
        ]
    }
];
module.exports.metadata = 
// TOP OF METADATA
{
    "cordova-plugin-whitelist": "1.3.4",
    "cordova-plugin-camera": "4.1.0",
    "commonBridge_plugin": "1.0.0"
}
// BOTTOM OF METADATA
});

并引入成功后;
在vue页面调用这个组件;

 btnClick(){
            let params = {
                "title":"标题",
                "content":"消息"
            }
            console.log('cordova---',cordova);
            cordova.plugins.commonBridge.goToNative(
                function(smg){
                    console.log('成功',smg)
                },
                function(smg){
                    console.log('失败',smg)
                },
                params
            )
        }

但是现在报错为:
Error: exec proxy not found for :: commonBridge :: goToNative
有人遇到过这个问题嘛??
我打印cordova是有这个方法的;不知道为什么报错了;

222.png

回复
阅读 1.6k
2 个回答

我已经解决了,原来是cordova的版本问题;我的版本是6.0,后端的版本是8.0;大家注意了;

我咋感觉你这个问题和cordova没多大关系呢,这看起来像是export和inport的关系,你这个goToNative是组件或者方法里暴露出来的,你需要import才能使用

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
你知道吗?

宣传栏