微信小程序模块化

109 阅读1分钟
function sayHello(name) { 
console.log(`Hello ${name} !`) 
} 
function sayGoodbye(name) { 
console.log(`Goodbye ${name} !`) 
} 
module.exports.sayHello = sayHello
exports.sayGoodbye = sayGoodbye 
var common = require('common.js') 
Page({ 
helloMINA: function() { 
common.sayHello('MINA')
},
goodbyeMINA: function() { 
common.sayGoodbye('MINA') 
} 
})