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()}`)

  

posted @ 2017-11-03 10:09  星光璀璨的夜空  阅读(197)  评论(0编辑  收藏  举报