NIUCLOUD是一款SaaS管理后台框架多应用插件+云编译。上千名开发者、服务商正在积极拥抱开发者生态。欢迎开发者们免费入驻。一起助力发展! 广告
### 1.第一种 `common.js` ~~~ export var a =10; ~~~ `index.js` ~~~ import {a} from "./common" ~~~ ### 2.第二种 `common.js` ~~~ var a =10; var b = 20; export { a, b } ~~~ `index.js` ~~~ import {a,b} from "./common" ~~~ ### 3.第三种引 `common.js` ~~~ var a =10; var b = 20; export default{ a, b } ~~~ > 一个模块只能有一个export default `index.js` ~~~ import common from "./common" console.log(common.a); console.log(common.b); ~~~ ## 4.第四种 common.js ``` function getData(){ console.log("data") } var a= 10; export { getData, a } ``` index.js ``` import {a,getData as get} from './common.js'; ```