'use strict'
var s = 'Hello'
function hello(name) {
console.log(s + ', ' + name + '!')
}
function hi(name) {
module.exports = {
hello: function(name) {
return hello(name)
},
hi: function(name) {
return hi(name)
// 引入hello模块:
var hello = require('./hello')
var s = 'Michael'
hello.hello(s)
hello.hi(s)
Sign in to make a reply
南极修炼千年的大冰块
hello.js内容如下
'use strict'
var s = 'Hello'
function hello(name) {
console.log(s + ', ' + name + '!')
}
function hi(name) {
console.log(s + ', ' + name + '!')
}
module.exports = {
hello: function(name) {
return hello(name)
},
hi: function(name) {
return hi(name)
}
}
main.js内容如下
'use strict'
// 引入hello模块:
var hello = require('./hello')
var s = 'Michael'
hello.hello(s)
hello.hi(s)