【问题标题】:Vue 3 + Typescript + JSX and img loading={"lazy"} give error: Property 'loading' does not exist on type 'ElementAttrs<ImgHTMLAttributes>'Vue 3 + Typescript + JSX 和 img loading={"lazy"} 给出错误:'ElementAttrs<ImgHTMLAttributes>' 类型上不存在属性 'loading'
【发布时间】:2021-03-03 17:11:55
【问题描述】:
Property 'loading' does not exist on type 'ElementAttrs<ImgHTMLAttributes>'
  • vue: ^3.0.0
  • @vue/babel-plugin-jsx: ^1.0.3
  • 打字稿:^3.9.9

【问题讨论】:

    标签: typescript vue.js vuejs3


    【解决方案1】:

    导入此代码后添加到您的main.ts

    // Fix: Property 'loading' does not exist on type 'ElementAttrs<ImgHTMLAttributes>'
    declare module "@vue/runtime-dom" {
        interface ImgHTMLAttributes extends HTMLAttributes {
            loading?: "lazy" | "eager" | "auto";
        }
    }
    

    【讨论】:

      猜你喜欢
      • 2023-01-03
      • 2022-06-22
      • 2020-01-18
      • 2019-03-07
      • 1970-01-01
      • 2019-02-18
      • 2019-07-10
      • 1970-01-01
      • 2019-11-26
      相关资源
      最近更新 更多