懒加载写法:在router.js
中
const router=[
{
path:'/', redirect:'/index'},
{
path:'/index', component: ()=>import('@/components/index')},
{
path:'/tiktok', component:()=>import('@/components/tiktok')}
];
// 路由对象
export default new VueRouter({
mode:'history',
routes: router
});