当前位置: 首页 > Web前端 > vue.js

vueroute懒加载的三种方式

时间:2023-03-31 14:14:56 vue.js

vueroute懒加载的三种方式方法一:结合vue异步组件和webpack代码constindex=r=>require.ensure([],()=>r(require('@/page/index')),'index')方法二:AMD写法constHome=resolve=>require(['../components/page/Home.vue'],resolve)方法三:ES6写法constChat=()=>import('@/components/page/Chat.vue')配置完成后,需要在newRouter中使用路由:[{path:'/index',component:Chat}]