【问题标题】:Display an image from url in ReactJS in tsx file在 tsx 文件中显示来自 ReactJS 中 url 的图像
【发布时间】:2021-02-01 07:56:33
【问题描述】:

我想在 React 中显示来自 URL 的图像。例如,我想要 tsx 文件中的这个图像

http://d1cs08zudd3ykv.cloudfront.net/dev/img/arrow-up.svg 在 reactJS 中显示。当我尝试使用时,要求不起作用,但要求正在使用本地路径。有没有可能做或者有没有其他方法可以做到这一点?又该怎么做呢?

【问题讨论】:

标签: reactjs image networking import tsx


【解决方案1】:

只需将图片src设置为图片的URL

const Component = (props) => {
  return (
    <div>
      <img src="http://d1cs08zudd3ykv.cloudfront.net/dev/img/arrow-up.svg" alt="" />
    </div>
  );
};

【讨论】:

    猜你喜欢
    • 2018-12-13
    • 1970-01-01
    • 1970-01-01
    • 2017-04-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多