vue3+vite2 抱错 vue-router.esm-bundler.js:72 [Vue Router warn]: Component “default” in record with path “/” is a Promise instead of a function that returns a Promise. Did you write “import(’./MyPage.vue’)” instead of “() => import(’./MyPage.vue’)” ? This will break in production if not fixed.

问题复现

  • 浏览器端console抱错

vue-router.esm-bundler.js:72 [Vue Router warn]: Component "default" in record with path "/" is a Promise instead of a function that returns a Promise. Did you write "import('./MyPage.vue')" instead of "() => import('./MyPage.vue')" ? This will break in production if not fixed.
  • terminal终端没报错
  • router代码如下

import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";const routes: Array<RouteRecordRaw> = [{path: "/",name: "Home",component: import(/* webpackChunkName: "about" */ "../views/Home.vue"),},{path: "/about",name: "About",// route level code-splitting// this generates a separate chunk (about.[hash].js) for this route// which is lazy-loaded when the route is visited.component: () =>import(/* webpackChunkName: "about" */ "../views/about.vue"),},
];const router = createRouter({history: createWebHashHistory(),routes,
});export default router;

原因分析与解决


import { createRouter, createWebHashHistory, RouteRecordRaw } from "vue-router";const routes: Array<RouteRecordRaw> = [{path: "/",name: "Home",component: () => import(/* webpackChunkName: "home" */ "@/views/Home.vue"),},{path: "/about",name: "About",component: () =>import(/* webpackChunkName: "about" */ "@/views/about.vue"),},
];const router = createRouter({history: createWebHashHistory(),routes,
});export default router;
  • webpackChunkName没有区分
  • component的引入格式为() => import(/* webpackChunkName: "about" */ "@/views/about.vue"),这个是主要问题。

报错 Component “default“ in record with path “/“ is a Promise instead of a function that return ...相关推荐

  1. [Vue Router warn]: Component “default“ in record with path “/xx“ is a function that does not return

    [debug日记] [Vue Router warn]: Component "default" in record with path "/xxx" is a ...

  2. 小程序插件封装Component报错 Component is not found in path……或 component is not defined

    小程序插件封装Component报错 小白程序猿,小程序在封装插件的时候遇到 Component报错,解决方式. # 提示为Component is not found in path--解决方式:排 ...

  3. vue3+cli4运行项目报错export ‘default‘ (imported as ‘VueRouter‘) was not found in ‘vue-router‘

    vue3+cli4运行项目报错export 'default' (imported as 'VueRouter') was not found in 'vue-router' 1.解决方案: cli3 ...

  4. openharmony编译报错ubuntu20.04按照官方文档,hb set报错为OHOS ERROR] Invalid vendor path: /home/openharmony/vendor

    ubuntu20.04按照官方文档,hb set报错为OHOS ERROR] Invalid vendor path: /home/openharmony/vendor 作者:坚果 公众号:" ...

  5. vue3.0引入ant-design-vue报错 export ‘default‘ (imported as ‘Vue‘) was not found in ‘vue‘

    vue3.0引入ant-design-vue报错 export 'default' (imported as 'Vue') was not found in 'vue' 报错如下 解决办法 根目录命令 ...

  6. 【已解决】Python安装TensorFlow报错“Consider adding this directory to PATH or, if you prefer to suppress this

    [已解决]Python安装TensorFlow报错"Consider adding this directory to PATH or, if you prefer to suppress ...

  7. CRMEB知识付费系统安装搭建【常见问题-19.支付宝支付报错invalid [default store dir]: /tmp/】

    支付宝支付 报错 invalid [default store dir]: /tmp/ 1.如果使用支付宝sdk,首先lotusphp_runtime 文件也要一起使用 支付宝现在的php sdk中有 ...

  8. 用vue-cli创建项目后npm run serve 报错Component name “main“ should always be multi-word vue/multi-word-compo

    1.报错 Component name "main" should always be multi-word vue/multi-word-component-names 原因: ...

  9. idea 启动报错: Failed to create JVM.JVM.Path XXXXXXX\jbr\ 我的解决办法

    idea 启动报错: Failed to create JVM.JVM.Path XXXXXXX\jbr\ 我的解决办法 在 C:\Users\Administrator\AppData\Roamin ...

最新文章

  1. 非修改md5视频去重消重软件视频去重视频消重怎么弄
  2. c++ opencv 通过网络连接工业相机_OpenCV项目实战之零件缺陷检测(上)
  3. 如何修改influxdb表结构_使用nginx-lua修改influxdb API的返回结构
  4. 打包跳过编译_Apache Flink v1.9-SNAPSHOT 源码编译
  5. 切点、切面:@Aspect、@PointCut相关的个人总结
  6. YBTOJ:字符串题(KMP)
  7. 两个富翁打赌_打赌您无法解决这个Google面试问题。
  8. ActionScript 3.0
  9. 网页编辑器粘贴word格式的处理
  10. layui 自定义request_Layui自定义模块的使用方式
  11. zxr10交换机配置手册vlan_最新中兴ZXR10交换机配置资料
  12. 手机app通用模板蓝色系用户登录页面
  13. 夏普Sharp MX-B401 一体机驱动
  14. Mathematica 分段函数 求导 求积分
  15. html 做填写的表格,CSS写的简单表格示例
  16. c# 检测中英输入法_用C#控制当前输入法
  17. 2021届 联发科技视频一面 嵌入式软件
  18. 抖音显示服务器升级要多久,抖音服务器升级要多久才能恢复正常
  19. 物联网发展存在的问题,具体有哪些?
  20. 锐捷网络2010年程序员C语言试题

热门文章

  1. 以太网帧格式与交换机原理
  2. 什么样的选择会大于努力?如何选?
  3. 白银时代房地产如何赚钱?——旅游地产怎样玩?
  4. 【Linux】目录结构和硬盘分区
  5. 给中国学生的第三封信(李开复)
  6. enet分割_Enet、refinenet多类别的语义分割的loss
  7. 捕获鼠标事件-JavaScript入门基础(005)
  8. 生活修行_身体心灵修行
  9. Rational Rhapsody C 双向传递
  10. Linux/centos下查看网卡型号,如何查看主板型号,CPU/显卡信息,硬盘型号等硬件信息...