-
node中的模块化导入导出
-
导出:
-
导出多个成员(必须在对象中)
-
exports.a = 123; exports.b ='hello'; exports.c=function(){ console.log('ccc'); }
-
接收
const a=require('./a.js')
到是一个对象 分别是abc -
特点:这种方式导出的是一个对象 ,收集了所有导出的值
-
-
导出单个成员(函数,字符串)
-
module.exports=123
-
这种导出的是一个值,且后者会覆盖前者
-
module.exports={ a:123, b:'123', c(){ console.log(123); } }
-
-
exports 和 module.exports 的区别
-
-