常见(性能一般)

    import Index from "@/components/index"
    const router = new Router({
        routes: [
            {
            path: '/',
            name: 'Index'
            component: Index,
            }
        ]
    })

性能有优化

const Index = (resolve) => {
  import('@/components/index').then((module) => {
    resolve(module);
  });
};
const router = new Router({
    routes: [
        {
        path: '/',
        name: 'Index'
        component: Index,
        }
    ]
})

路由懒加载(性能较优,推荐使用)

const index = require('@/components/index');
const Index = resolve => require.ensure([], () => resolve(index), 'list');
const router = new Router({
    routes: [
        {
        path: '/',
        name: 'Index'
        component: Index,
        }
    ]
})
Logo

前往低代码交流专区

更多推荐