使用url React下载图像 [英] Download Image with url React

查看:52
本文介绍了使用url React下载图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在图片库上工作。
我试图建立一种机制,允许用户按下按钮并下载图像。
我有图片的网址。我该怎么做?

Im working on a picture gallery. Im trying to make a mechanism that allows user to press button and download image. I have a url to the image. How can I do this?

推荐答案

使用链接标签的下载属性:

Use download attribute of link tag:

<a href="path-to-image.jpg" download>
  <img src="path-to-image.jpg" />
</a>

另外,请小心使用下载属性时发布语句。

这篇关于使用url React下载图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆