模块化有俩个核心:导入和导出
代码语言:javascript复制//CommonJS的导出
module.exports = {
flag: true,
test(a, b) {
return a b
},
demo(a, b) {
return a * b
}
}
//CommonJS的导出
let { test, demo, flag} = require('moduleA');
//等同于
let mA = require('moduleA');
let test = mA.test;
let demo = mA.demo;
let flag = mA.flag;