ES6学习---模块化
作者:互联网
//1. 通用的导入方式 //引入 m1.js 模块内容 import * as m1 from "./src/js/m1.js"; // //引入 m2.js 模块内容 import * as m2 from "./src/js/m2.js"; // //引入 m3.js import * as m3 from "./src/js/m3.js"; //2. 解构赋值形式 as后跟着别名 就相当于 school的别名是 guigu import {school, teach} from "./src/js/m1.js"; import {school as guigu, findJob} from "./src/js/m2.js"; import {default as m3} from "./src/js/m3.js"; //3. 简便形式 针对默认暴露 import m3 from "./src/js/m3.js"; console.log(m3);
分别暴露
//分别暴露 export let school = '尚硅谷'; export function teach() { console.log("我们可以教给你开发技能"); }
统一暴露
//统一暴露 let school = '尚硅谷'; function findJob(){ console.log("我们可以帮助你找工作!!"); } // export {school, findJob};
默认暴露
//默认暴露 export default { school: 'ATGUIGU', change: function(){ console.log("我们可以改变你!!"); } }
标签:ES6,school,src,模块化,暴露,js,---,m3,import 来源: https://www.cnblogs.com/leiyanting/p/15392959.html