nodejs中一个js文件就可以看做是一个模块

在node环境中,可以直接var a=require('模块路径以及不带扩展名的模块名')

exports---module.exports

其中node准备好了module变量,

var module={

  id:'hello',

  exports:{}

};

输出模块变量,最好都用module.exports=''或者函数;当赋值不是函数或者数组时,可以对exports直接赋值,建议统一使用module.exports=进行赋值

相关文章:

  • 2021-07-04
  • 2021-08-11
  • 2021-05-22
  • 2021-04-07
  • 2022-01-26
  • 2022-02-28
  • 2021-09-05
  • 2021-11-17
猜你喜欢
  • 2021-11-10
  • 2021-07-27
  • 2021-08-02
  • 2022-01-15
  • 2021-06-26
  • 2021-10-20
  • 2022-01-02
相关资源
相似解决方案