var BTY_CONFIG = (function () {
var config = {
planet: [{
name: '电子',
link: 'https://www.baidu.com/?电子'
}, {
name: '大数据',
link: 'https://www.baidu.com/?数据'
}],
share: [,
'霍尔拖',
'发区'
],
collection: ['数据共享交换', '信用信息共享']
};
return config;
}());
require('./config.js');
console.log(BTY_CONFIG.planet[1].name)

/*
var BTY_CONFIG = (function () {
var config = {
planet: [{
name: '电子',
link: 'https://www.baidu.com/?电子'
}, {
name: '大数据',
link: 'https://www.baidu.com/?数据'
}],
share: [,
'霍尔拖',
'发区'
],
collection: ['数据共享交换', '信用信息共享']
};
return config;
}());
*/
const BTY_CONFIG = {
planet: [{
name: '电子',
link: 'https://www.baidu.com/?电子'
}, {
name: '大数据',
link: 'https://www.baidu.com/?数据'
}],
share: [,
'霍尔拖',
'发区'
],
collection: ['数据共享交换', '信用信息共享']
};
export default BTY_CONFIG
// require('./config.js');
// console.log(BTY_CONFIG.planet[1].name)
import BTY_CONFIG from './config.js'
console.log(BTY_CONFIG.planet[0].name)
BTY_CONFIG是模块的内部变量,你没有导出, 使用
或者
或者
反正你要把这个变量导出来