node-记录1

  1. node中的模块化导入导出

    1. 导出:

      1. 导出多个成员(必须在对象中)

        1. exports.a = 123;
          exports.b ='hello';
          exports.c=function(){
          	console.log('ccc');
          }
          
        2. 接收const a=require('./a.js')到是一个对象 分别是abc

        3. 特点:这种方式导出的是一个对象 ,收集了所有导出的值

      2. 导出单个成员(函数,字符串)

        1. module.exports=123

        2. 这种导出的是一个值,且后者会覆盖前者

        3. module.exports={
          	a:123,
          	b:'123',
          	c(){
          		console.log(123);
          	}
          }
          
      3. exports 和 module.exports 的区别

posted @ 2021-05-24 21:43  有风吹过的地方丨  阅读(31)  评论(0编辑  收藏  举报