💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、豆包、星火、月之暗面及文生图、文生视频 广告
[TOC] ## es6模块化的三种方式 ### 第一种 `common.js` ``` var a = 10; function b(){ console.log("b"); } export {a,b} ``` `index.js` ``` //导入 import {a,b} from "/common" //使用 console.log(a) b() ``` ### 第二种 `common.js` ``` var a = 10; function b(){ console.log("b"); } export default{ a, b } ``` `index.js` ``` //导入 import test from "/common" //使用 console.log(text.a); text.b() ``` ### 第三种 不推荐使用 `common.js` ``` export var c = 20; ``` `index.js` ``` //导入 import {c} from "/common" 使用 console.log(c) ```