如何在 Vue 中增加 `ElementAttrs<HTMLAttributes>` 接口?

问题描述

我将 Vue 3 与 TSX 一起使用,如何增强 GameObject 接口,以便我可以在不出现类型错误的情况下执行以下操作?

GameObject

我得到的错误是:

ElementAttrs<HTMLAttributes>

解决方法

我已经想通了:

// Import an entire module for side effects only,without importing anything.
// This runs the module's global code but doesn't actually import any values.
import 'vue'

declare module 'vue' {
  interface HTMLAttributes {
    vLoading?: unknown
  }
}