ES6框架的搭建

 1.引入traceur.js  http://google.github.io/traceur-compiler/bin/traceur.js

2.Traceur编译器用于网页

new traceur.WebPageTranscoder(document.location.href).run();

 

3.<script type="module">代码内容</script>

注意,script标签的type属性的值是module,而不是text/javascript。这是Traceur编译器识别ES6代码的标识,编译器会自动将所有type=module的代码编译为ES5,然后再交给浏览器执行。

原文地址:https://www.cnblogs.com/SPHmomo/p/7531943.html