babel-plugin-syntax-dynamic-import 插件语法动态导入
参考文档
https://babeljs.io/docs/en/babel-plugin-syntax-dynamic-import/
https://babeljs.io/docs/en/configuration
1. 安装
-
npm install --save-dev @babel/plugin-syntax-dynamic-import
2.使用
1. 通过 .babelrc (推荐)
-
// JSON
-
module.exports = {
-
presets: ['@vue/app'],
-
plugins: ['@babel/plugin-syntax-dynamic-import']}
import('./a.js').then(()=>{ console.log('a.js is loaded dynamically'); });