123456789101112 |
- console.log('index.js加载')
- // import {mul} from './test'
- //懒加载 点击按钮时再加载test.js 不会重复加载
- document.getElementById("btn").onclick = function(){
- //分割代码 webpackPrefetch:true 预加载:提前加载js文件
- import(/* webpackChunkName: 'test',webpackPrefetch: true */'./test').then(({mul})=>{
- console.log(mul(3,5))
- })
- }
|