AMD模块&CommonJs模块&ES6模块

AMD模块:

define(function (require) {
    //通过模块加载路径获得依赖模块
    const bar = require('./bar');
    //模块产出
   return function () {
        //............
        };
})
        

CommomJS模块:

// 通过相对路径获得依赖模块
const bar = require ('./bar');
//模块产出
module.exports = function () {
     //.........
};

ES6模块:

// 通过相对路径获得依赖模块
import bar from './bar';
//模块产出
export default function () {
    //....  
}

  

  

原文地址:https://www.cnblogs.com/lonelyGentleman/p/6867781.html