• 加载器中的预编


      if (_type == "js") {//js预编译
                        var _script = "_define(function(exports,module){
    ";
                        _script += "var $parent = "" + _basePath + "";
    ";
                        _script += data.replace(/require(/g, "_require($parent,");
                        _script += ";
    });" + "//@ sourceURL=" + _absUrl(path);
                        _moudle = window["eval"](_script);
    }

    上面这段程序会把下面的代码

    exports.txt = "hello word";
    var rep=require("./js/moule");
    module.exports={
        "name":"张三"
    }

    预编译为

    _define(function(exports,module){
    var $parent = "";
    exports.txt = "hello word";
    var rep=_require($parent,"./js/moule");
    module.exports={
        "name":"张三"
    };
    });//@ sourceURL=http://localhost:63342/jiaocheng/moudle.js

    1.加上了_define(function(exports,module){ 

    2.var rep=require("./js/moule"); 变为了var rep=_require($parent,"./js/moule");

    3.加上了var $parent = "";  $parent 是 当前js 的路径,因为 当前js在根目录 所以$parent为空

  • 相关阅读:
    Neko Performs Cat Furrier Transform CodeForces
    Neko does Maths CodeForces
    Game HDU
    HDU
    CF1155D Beautiful Array 贪心,dp
    二维差分
    B
    一维差分
    状压dpHDU
    [转载] HBase vs Cassandra:我们迁移系统的原因
  • 原文地址:https://www.cnblogs.com/blowfish/p/3785215.html
Copyright © 2020-2023  润新知