第一种:exports
// 定义方法,常量
const myPI = 3.14
const add = (a,b) => a + b;
// 导出
// 方法一:
exports.myPI = myPI
exports.add = add
第二种:module.exports
// 定义方法,常量
const myPI = 3.14
const add = (a,b) => a + b;
// 方法二:
module.exports.myPI = myPI
module.exports.add = add
第二种方法的变形用法
// 定义方法,常量
const myPI = 3.14
const add = (a,b) => a + b;
// 方法二(变形)
module.exports = {
myPI,
add
}