# any require(string path)
Introduce module. Return to the module module.exports
or exports
Exposed interface.
# parameter
Name | type | Introductions |
---|---|---|
path | string | You need to introduce the relative path of the module file relative to the current file, or the npm module name, or npm modules path. Absolute path is not supported |
# sample code
// common.js
function sayHello(name) {
console.log(`Hello ${name} !`)
}
function sayGoodbye(name) {
console.log(`Goodbye ${name} !`)
}
module.exports.sayHello = sayHello
exports.sayGoodbye = sayGoodbye
where common = require('common.js')
Page({
helloMINA: function() {
common.sayHello('MINA')
},
goodbyeMINA: function() {
common.sayGoodbye('MINA')
}
})