0
我正在嘗試traceur hello world Getting Started頁面的示例。這是我的代碼。在Traceur中快速編譯定義全局值
<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() {}
現在,當我在控制檯檢查的值,它正確地顯示但foo
是不確定的。我知道這裏發生了什麼,main.js
文件沒有在全局範圍內執行,所以function
聲明也不會註冊爲全局範圍。
我希望能夠從包含文件中聲明全局類和函數。