报错

类型“{ $: ComponentInternalInstance; $data: {}; $props: Partial<{}&gt; &amp; Omit<Readonly<{} &amp; {} &amp; {}&gt; &amp; VNodeProps &amp; AllowedComponentProps &amp; ComponentCustomProps, never&gt;; … 10 more …; $watch(source: string | Function, cb: Function, options?: WatchOptions<…&gt; | undefined): WatchStopHandle; } &amp; … 4 more … &amp; ComponentC…”上不存在属性xxxxx”。

找到文件shimsvue.d.ts 或者新建一个`.ts`或”.d.ts文件

添加以下代码

export {}

declare module 'vue' {
  interface ComponentCustomProperties {
    $filters: any
  }
}

注意:一定要添加export {} 不然会覆盖掉原来的

参考vue3官方文档TypeScript 与选项式 API | Vue.js

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注