You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决Vuetify中Argument is not assignable to parameter of type 'never'错误?

解决Vuetify中v-btn类型错误:Argument of type '{ rounded: boolean; color: string; variant: string; onClick: any; }' is not assignable to parameter of type 'never'

这个错误是因为TypeScript无法正确识别Vuetify组件的Prop类型,导致组件参数被推断为never类型,和传入的属性不匹配。以下是具体解决步骤:

  • 配置TypeScript识别Vuetify类型
    修改项目根目录下的tsconfig.json,在compilerOptions里把vuetify加入types数组:

    {
      "compilerOptions": {
        // 保留原有配置
        "types": ["vuetify"]
      }
    }
    
  • 添加Vuetify类型引用声明
    如果上面的配置没效果,在src/env.d.ts(或src/shims-vuetify.d.ts)中添加类型引用:

    /// <reference types="vuetify" />
    
  • 更新Vuetify到最新稳定版
    旧版本Vuetify可能存在类型定义bug,执行命令更新:

    npm update vuetify
    

完成以上操作后,重新运行npm run build即可解决该类型错误。

内容的提问来源于stack exchange,提问作者Rohan Jayaraj

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.17 01:52:06