0
点赞
收藏
分享

微信扫一扫

js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function

小桥流水2016 2022-03-18 阅读 96

js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function
js: Uncaught TypeError: channel.execCallbacks[message.id] is not a function

QWebChannel Qt与网页交互过程中 明明没有错,却报上面的错误

原来是这样写的,声明了多个接收QT对象报上面的错误

$.extend({
//获取设备名称
queryEquipmentName:function()
{  new QWebChannel(qt.webChannelTransport,function(channel)
       {
       //FileSelect
       // js 调用QT 
       var jsqtBridge =channel.objects.jsqtbridgeobj;
       window.foo=jsqtBridge;
      jsqtBridge.getbdname(function(content){
               console.log(content);
                //alert(content);
                //window.wxc.xcConfirm("1111"+content, window.wxc.xcConfirm.typeEnum.info);
                $("#dltc_20220318_shipName").html(content);
               });
});

},
//获取设备id
queryEquipmentID:function()
{  new QWebChannel(qt.webChannelTransport,function(channel)
       {
       //FileSelect
       // js 调用QT 
       var jsqtBridge =channel.objects.jsqtbridgeobj;
       window.foo=jsqtBridge;
      jsqtBridge.getbdid(function(content){
               console.log(content);
                //alert(content);
                //window.wxc.xcConfirm("1111"+content, window.wxc.xcConfirm.typeEnum.info);
                  $("#dltc_20220318_equipmentID").html(content);

               });
});

},
//获取设备级别
queryEquipmentLevel:function()
{  new QWebChannel(qt.webChannelTransport,function(channel)
       {
       //FileSelect
       // js 调用QT 
       var jsqtBridge =channel.objects.jsqtbridgeobj;
       window.foo=jsqtBridge;
      jsqtBridge.getbdlevel(function(content){
               console.log(content);
                //alert(content);
                //window.wxc.xcConfirm("1111"+content, window.wxc.xcConfirm.typeEnum.info);
                $("#dltc_20220318_shipType").html(content);

               });
});

}


});

分析:

        因为上面是粗暴复制的,如果连续调用,在上下文中很容易出现,上面一个方法还没有执行完成,就被下面一个方法铲掉,总会有方法无法调用,是一个简单的错误

修改为如下,马上ok

$.extend({
//ALL 获取设备级别+//获取设备id//获取设备名称
queryEquipmentInformationALL:function()
{  new QWebChannel(qt.webChannelTransport,function(channel)
       {

       // js 调用QT
       var jsqtBridge =channel.objects.jsqtbridgeobj;
       window.foo=jsqtBridge;
       //获取设备名称
        jsqtBridge.getbdname(function(content){
                 console.log(content);
                  //alert(content);
                 // window.wxc.xcConfirm("queryEquipmentName"+content, window.wxc.xcConfirm.typeEnum.info);
                  $("#dltc_20220318_shipName").html(content);
                 });
       //获取设备级别
      jsqtBridge.getbdlevel(function(content){
               console.log(content);
               // alert(content);
               // window.wxc.xcConfirm("queryEquipmentLevel"+content, window.wxc.xcConfirm.typeEnum.info);
                $("#dltc_20220318_shipType").html(content);

               });
               //获取设备id
        jsqtBridge.getbdid(function(content){
                 console.log(content);
                 // alert(content);
                 // window.wxc.xcConfirm("queryEquipmentLevel"+content, window.wxc.xcConfirm.typeEnum.info);
                  $("#dltc_20220318_shipType").html(content);

                 });
});

}


});
举报

相关推荐

0 条评论