Node.js的学习入门(一、module.exports与exports)
/*User.js*/ exports.userName = 'Tom'; exports.sayHello = function () { return 'wwwwww' } /*或者*/ module .exports = { userName:"jack", sayHello: function () { return 'Hello'; } } /*引用*/ let user = require('./User'); console.log(`userName:${user.userName}`) console.log(`i'm ${user.userName},I say ${user.sayHello()}`)