//1.创建测试模块js文件(我这里命名为test.js)

//2.添加测试方法

function test(){

  console.log('Test Success!');

}

//3.公开该方法到node模块

//exports.test(这个是public的方法名,外部调用的时候,使用这个方法名)

exports.test = test;

//4.测试(在另一个js文件中引入这个模块,并调用对应测试函数,两个js文件在同一目录下)

const testModule = require('./test.js');

testModule.test();

 

相关文章:

  • 2021-09-19
  • 2021-06-25
  • 2022-12-23
  • 2021-12-20
  • 2021-12-20
  • 2022-02-27
  • 2022-01-06
猜你喜欢
  • 2021-07-05
  • 2021-05-04
  • 2021-10-24
  • 2021-10-17
  • 2022-12-23
  • 2021-11-01
相关资源
相似解决方案