<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>esmodule</title> </head> <body> <div id="app"></div> </body> </html> <script type="module" src="main.js"></script> <!--type : module 告訴瀏覽器這裏引入的是模塊的形式-->
//1.單獨導出 export let num=10000; export let str="hello"; //默認導出的形式 {num,str}
導入的時候用:import {num,str} from "./zf.js";
也可以一次性獲取出來:import * as zf from "./zf.js";
//2.使用default導出,可以一次性導入 export default {arr,str};
導入的時候用:import px from "./px.js";