注意:最新版本的chrome浏览器已支持module语法,需要在web服务器环境下运行!
设置浏览器启用es6语法功能:
1.在浏览器的url中输入:chrome://flags/
设置下面选项为enable,重启浏览器。

准备代码:
2.index.html
    <!DOCTYPE html>
    <html lang="en"> 
    <head>    
    <meta charset="UTF-8">    
    <title>Document</title>    
    <script type="module" src="module1.js"></script>    
    </head> 
    <body>
    </body> 
    </html>
 
3.module1.js
import {show} from './module2.js';show();
 
4.module2.js
export function show(){    i++;    console.log(i);}var i=0;
 
在浏览器端打开调试:

ok!



















