【发布时间】:2020-07-20 13:35:57
【问题描述】:
我有这个问题,因为 const 变量没有被提升并且应该抛出一个语法错误。
为什么这段代码有效?
export let testModule = () => {
let test = document.querySelector('.test');
test.innerHTML = myText;
test.style.cssText = 'color: red';
}
const myText = 'IT WORKS!!!!!'
如果您想自己检查,我已附上工作插件:https://plnkr.co/edit/TR8SvCjQgqPDWpI3?preview
【问题讨论】:
标签: ecmascript-6 import module export hoisting