module.exports---require案例export--import案例

 module.exports---require案例

//config.js
module.exports = {
    userName:'zhangdan',
    say:function () {
        return 'hello';
    }
}

exports.userName = "tom";
exports.say = function () {
    return "hello";
}
var config = require('config.js')
var username= config.userName

export--import案例

//config.js
var apiServer = 'http://127.0.0.1:3000'


function add(a,b) {
  return a+b;
}

export {apiServer,add}
 import {apiServer,add} from '../../config'

  console.log(apiServer);
  console.log(add(1, 2));

 

 

你可能感兴趣的:(Node)