首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >【vue3】Argumnt of type ‘history:RouterHistory;}is not assignable to paraeter of type ‘RouterOptions‘.

【vue3】Argumnt of type ‘history:RouterHistory;}is not assignable to paraeter of type ‘RouterOptions‘.

作者头像
fruge365
发布2025-12-15 10:36:03
发布2025-12-15 10:36:03
1000
举报

今天vue-router突然报错

Argument of type 'history:RouterHistory;}is not assignable to parameter of type ‘RouterOptions’. Property 'routes’is missing in type 'history:RouterHistory;}but required in type ‘RouterOptions’.ts(2345)

以前从来没出错过,今天突然不知道为啥抽风了

解决办法:

加个类型断言RouterOptions 即可

代码语言:javascript
复制
import type { RouterOptions } from 'vue-router'
代码语言:javascript
复制
const router = createRouter({
    history: createWebHashHistory(),
} as RouterOptions)  // 在此处加个类型断言即可

搞定~

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2023-10-27,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 解决办法:
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档