如今ES6用的愈來愈多,想要學習使用ES6,只需簡單搭建引入幾個js便可運行ES6代碼javascript
可是須要基本的服務器環境下運行(如http://10.12.8.161:8047/js-test/export/export.html 這樣服務器環境訪問)。html
引入這幾個jsjava
<script type="text/javascript" src="./bower_components/jQuery/dist/jquery.min.js"></script> <script type="text/javascript" src="./bower_components/traceur/traceur.js"></script> <script type="text/javascript" src="./bower_components/bootstrap/dist/js/bootstrap.js" ></script>
ES6 js 文件運行須要設置
type="module"jquery
<script type='module'> import * as cc from './js/main.js'; console.log(cc); </script>
完整示例:es6
<html> <head> <meta charset="UTF-8"> <title>es6</title> <script type="text/javascript" src="./bower_components/jQuery/dist/jquery.min.js"></script> <script type="text/javascript" src="./bower_components/traceur/traceur.js"></script> <script type="text/javascript" src="./bower_components/bootstrap/dist/js/bootstrap.js" ></script> <script type="text/javascript"> //traceur.options.experimental = true; </script> </head> <body> <script type='module'> import * as cc from './js/main.js'; console.log(cc); </script> </body> </html>
下載:bootstrap