vue 路由三种写法方式
常见(性能一般)import Index from "@/components/index"const router = new Router({routes: [{path: '/',name: 'Index'component: Index,...
·
常见(性能一般)
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,
}
]
})
更多推荐
已为社区贡献6条内容
所有评论(0)