【问题标题】:React + Typescript : TypeScript error: Type 'string' has no properties in common with type 'CSSProperties'React + Typescript:TypeScript 错误:类型“字符串”与类型“CSSProperties”没有共同的属性
【发布时间】:2019-09-09 09:55:40
【问题描述】:

我正在使用带有 React 的 Typescript,目前正面临这个问题

【问题讨论】:

    标签: css reactjs typescript


    【解决方案1】:

    style 属性需要一个具有样式属性而不是字符串的对象:

    style={{
        backgroundImage: "url('https://source.unsplash.com/07fzqFEfLlo/1920x1080')"
    }}
    

    See the React docs on the subject.

    【讨论】:

      猜你喜欢
      • 2019-07-03
      • 2019-08-03
      • 2023-01-05
      • 2021-06-29
      • 2021-06-02
      • 2017-11-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多