vue-router从2.x升级到4.x, 路由模块按需加载改写方式
直接升级,用原来的代码,会报错
Failed to mount component: template or render function not defined
旧的写法
const webIndex = () => import('@/pages/index.vue');
const routes = [
{
path: '/',
name: 'index',
component: webIndex
}];新的写法:
const webIndex = () => import('@/pages/index.vue').then(m => m.default);
const routes = [
{
path: '/',
name: 'index',
component: webIndex
}];本文内容仅供个人学习、研究或参考使用,不构成任何形式的决策建议、专业指导或法律依据。未经授权,禁止任何单位或个人以商业售卖、虚假宣传、侵权传播等非学习研究目的使用本文内容。如需分享或转载,请保留原文来源信息,不得篡改、删减内容或侵犯相关权益。感谢您的理解与支持!