commonjs规范
1.创建模块 创建js文件
2.暴露模块 module.exports \ export default
3.加载模块 require \ import
4.使用模块
a.js
let a=20;
module.exports.a=a;
b.js
const a=require("./a")
console.log(a);
本文详细介绍了CommonJS模块化规范的基本概念,包括如何通过创建JS文件来定义模块,使用module.exports进行模块的导出,利用require加载并使用模块等内容。
commonjs规范
1.创建模块 创建js文件
2.暴露模块 module.exports \ export default
3.加载模块 require \ import
4.使用模块
a.js
let a=20;
module.exports.a=a;
b.js
const a=require("./a")
console.log(a);
1307

被折叠的 条评论
为什么被折叠?