vue实现路由懒加载
未懒加载的路由
import Rou from '@/views/rou.vue' const router = new VueRouter({ routes: [ { path: '/rou', component: Rou } ] })
懒加载
方案一:
const Rou = () => import('@/views/rou.vue') const router = new VueRouter({ routes: [ { path: '/rou', component: Rou } ] })
方案二
// 省去import const router = new Router({ routes: [ { path: '/rou',
name: 'Rou' component: (resolve) => {require(['@/views/rou.vue'], resolve) }
}
]
})
我其实也有努力呀