export default语法在bebel转义后会丢失作用域,代码如下
export default {
host: 'localhost',
port: 80
}
babel转译后
module.exports.default = {
host: 'localhost',
port: 80
}
解决方案
// main.js
import { foo, bar } from "./static"
// static.js
let foo = "foo"
let bar = "bar"
export { foo, bar }