Browser plug-in development - inject layer error into Baidu (layer error Cannot read property 'extend' of undefined)

The jQuery on Baidu's homepage is refactored by Baidu itself. If you directly call Baidu's jQuery without injecting the complete jQuery, this situation will occur. Secondly, Baidu has a modular define that is also refactored, which will also cause errors. The solution is to decompress the layer. ,Modify the entry call and
insert image description here
remove the red code, or copy the code below and replace it directly

// 搜索该代码
e.layui && layui.define ? (r.ready(), layui.define("jquery", function(t) {
       r.path = layui.cache.dir, o.run(layui.$), e.layer = r, t("layer", r);
   })) : "function" == typeof define && define.amd ? define([ "jquery" ], function() {
       return o.run(e.jQuery), r;
   }) : function() {
       o.run(e.jQuery), r.ready();
   }();
// 修改为如下代码
e.layui && layui.define ? (r.ready(), layui.define("jquery", function(t) {
        r.path = layui.cache.dir, o.run(layui.$), e.layer = r, t("layer", r);
    })) :  function() {
        o.run(e.jQuery), r.ready();
    }();

 

Guess you like

Origin blog.csdn.net/weixin_55305220/article/details/122025592