本文主要是介绍node模块化之模块导出导入,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
//此时是等价的
exports.name = 'xxx'
module.exports.sex = '男'
//此时把module.export指向的对象改变,以module.exports为准
module.exports = {
id:'1',
girlfriend:{
name:'yyy'
}
}
exports是module.exports的别名(地址引用关系),最终导出对象以module.exports为准
导入时配合解构赋值
const {girlfiend} = require('xxx.js')
node中好像不支持 import xxx from yyy这种方式
这篇关于node模块化之模块导出导入的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!