【发布时间】:2019-05-12 09:23:08
【问题描述】:
我有两个文件,file1 导出一个变量 'not a constant' var x=1 和 file2 从中导入这个变量
问题是我无法修改导入的变量,即使它不是常量!
file1.js
export var x=1 //it is defined as a variable not a constant
file2.js
import {x} from 'file1.js'
console.log(x) //1
x=2 //Error: Assignment to constant variable
【问题讨论】:
标签: javascript node.js ecmascript-6 es6-modules es6-module-loader