【Vue-Router】路由懒加载的几种方式

路由懒加载

  • 非懒加载
  • require 异步加载 ‘@/components/home’
  • import 引入,动态加载

非懒加载

import Home form './home.vue';

// ...
{
	name: 'Home',
	path: '/home',
	component: Home
}

require 异步加载 ‘@/components/home’

{
	name: 'Home',
	path: '/home',
	component: resolve => require(['@/components/home'], resolve)
}

import 引入,动态加载

{
	name: 'Home',
	path: '/home',
	component: () => import('@/pages/Home/index.vue')
}

你可能感兴趣的:(Vue,项目问题,vue.js,javascript,前端)