如何解决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
相关产品推荐
相关产品推荐

