【问题标题】:TypeScript does not accept video autoplay, why?TypeScript 不接受视频自动播放,为什么?
【发布时间】:2021-11-12 11:02:18
【问题描述】:

收到此错误:

  Property 'autoplay' does not exist on type 'DetailedHTMLProps<VideoHTMLAttributes<HTMLVideoElement>, HTMLVideoElement>'. Did you mean 'autoPlay'?

  207 |               playsInline
  208 |               controls={props.isControlsVisible == true}
> 209 |               autoplay={props.isAutoPlay == true}
      |               ^

奇怪,因为这里的文档说它是一个有效的属性。

https://www.w3schools.com/tags/att_video_autoplay.asp

【问题讨论】:

    标签: javascript reactjs typescript video


    【解决方案1】:

    将自动播放更改为自动播放。这是一个 JSX 约定,其中一些 DOM 道具与规范不匹配。

    这是一个 GitHub 问题,详细解释了为什么它是 Camelcase:https://github.com/facebook/react/issues/16762

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多