我正在尝试他们的Getting Started页面上的traceur hello world示例。这是我的代码。
<script src="https://google.github.io/traceur-compiler/bin/traceur.js"></script>
<script src="https://google.github.io/traceur-compiler/bin/BrowserSystem.js"></script>
<script src="https://google.github.io/traceur-compiler/src/bootstrap.js"></script>
<script type="module">
import 'main.js';
</script>main.js有这样的功能:
window.a = 10;
function foo() {}现在,当我在控制台中检查a的值时,它显示正确,但foo未定义。我知道这里发生了什么,main.js文件没有在全局作用域中执行,所以function声明也不会注册到全局作用域。
我希望能够在包含的文件中声明全局类和函数。
https://stackoverflow.com/questions/38317756
复制相似问题