# any require(string path)
Introduces a module. The module is returned by module.exports
or the API exposed by exports
.
# Parameters
Name | Type | Description |
---|---|---|
path | string | The relative path of the file of the module to be introduced, relative to the current file, or the NPM module name or NPM module path. This parameter does not support absolute paths. |
# 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
var common = require('common.js')
Page({
helloMINA: function() {
common.sayHello('MINA')
},
goodbyeMINA: function() {
common.sayGoodbye('MINA')
}
})