Node 导入导出

A模块代码*(准备暴露add方法)

const add = (n1, n2) => n1 + n2;

exports.add = add;

B模块(接受A模块add方法)


//const a = require('./a.js');
const a = require('./a');
console.log(a.add(10, 20));
posted @ 2020-05-12 21:19  乾子  阅读(205)  评论(0编辑  收藏  举报