(function {})(this, function(){})的(function {})

module.exports怎么理解?


(function {})(this, function(){})的(function {})和this参数怎么理解?



(function webpackUniversalModuleDefinition(root, factory) {

    if(typeof exports === 'object' && typeof module === 'object')

        module.exports = factory(require("echarts"));

    else if(typeof define === 'function' && define.amd)

        define(["echarts"], factory);

    else if(typeof exports === 'object')

        exports["echarts-gl"] = factory(require("echarts"));

    else

        root["echarts-gl"] = factory(root["echarts"]);

})(this, function(__WEBPACK_EXTERNAL_MODULE_0__) {

return /******/ (function(modules) { }


长风秋雁
浏览 620回答 1
1回答

梦里花落0921

就是一个立刻调用的匿名函数(function(root,factory){    //root 因为直接调用所以this是全局对象,浏览器环境为window,node环境为global    //factory() 返回1})(this,function(){    return 1});module.exports = factory(require("echarts")); node环境define(["echarts"], factory); 第三方模块加载插件root["echarts-gl"]; window环境
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript