暴露接口
- 模塊只有通過module.exports或者 exports才能對外暴露接口
推薦開發(fā)者采用module.exports來暴露模塊接口
*小程序目前不支持直接引入node_modules,開發(fā)者需要使用到node_modules時候建議拷貝出相關(guān)的代碼到小程序的目錄中。
function sayHello(name) {
console.log('Hello ${name} !')
}
module.exports.sayHello = sayHello
引入公共代碼
var common = require('common.js')
common.sayHello('MINA')
!!require暫時不支持絕對路徑!!