1.应用场景
主要用于学习, 使用ES6的导入导出模块, 以及动态导入的用法. |
2.学习/操作
1.文档阅读 https://es6.ruanyifeng.com/#docs/module // Module 的语法 2.整理输出 TBD 动态导入模块, 有时要根据环境不同, 动态导入[是否导入, 或不同]模块, ES6的解决方案: ES2020提案 引入 Note:
扫描二维码关注公众号,回复:
12889184 查看本文章
上面代码中,
它是运行时执行,也就是说,什么时候运行到这一句,就会加载指定的模块。 另外,
Code:
优化 async / await 同时导入多个模块
可以看到打包后的文件目录 // 单独为四个文件, 按需加载 后续补充 ... |
3.问题/补充
1.动态导入模块, 是否用AMD比有Module更好一些? https://humanwhocodes.com/blog/2016/04/es6-module-loading-more-complicated-than-you-think/ // ES6 module loading: More complicated than you think 2. 如果使用 CommonJs规范去实现动态加载? ... |
4.参考
https://es6.ruanyifeng.com/#docs/module // Module 的语法 https://humanwhocodes.com/blog/2016/04/es6-module-loading-more-complicated-than-you-think/ // ES6 module loading: More complicated than you think |
后续补充
...