首页 > 其他分享 >vue路由懒加载(延迟加载)的写法..

vue路由懒加载(延迟加载)的写法..

时间:2022-10-06 06:55:05浏览次数:55  
标签:Index vue .. index 首屏 写法 路由 加载

路由懒加载可以帮我们在进入首屏时不用加载过度的资源,从而减少首屏加载速度

(1)路由文件中,非懒加载写法:

import Index from '@/page/index/index';
export default new Router({  
    routes: [    
        { 
            path: '/', 
            name: 'Index',     
            component: Index 
        }
    ]
})

(2)路由懒加载写法:

export default new Router({
  routes: [    
        { 
            path: '/', 
            name: 'Index', 
            component: resolve => require(['@/view/index/index'], resolve) 
        }
   ]
})

标签:Index,vue,..,index,首屏,写法,路由,加载
From: https://www.cnblogs.com/mahmud/p/16756955.html

相关文章