网上已经有很详细的介绍了,这里补充一点
function
sayHello(name) {
return
'Hello '
+ name
}
function
sayGoodbye(name) {
return
'Goodbye '
+ name
}
js里面有两个方法时,对外暴露有两种写法都可以
官方文档是这样
module.exports.sayHello = sayHello
exports.sayGoodbye = sayGoodbye
这样写也一样效果
module
.exports = { sayHello: sayHello,
sayGoodbye: sayGoodbye }
以下是一个小程序模块化的详细介绍链接
https://www.cnblogs.com/panlaixing/p/6736499.html