[英]How to make a download button for image in nextjs
Thanks to people who had contribute to answer my question.感谢那些为回答我的问题做出贡献的人。 I found a way to make the download button by installing 'js-file-download' and call a function like this.
我找到了一种通过安装“js-file-download”并调用这样的函数来制作下载按钮的方法。
const getPicture = async () => {
axios({
url: 'whatever file link you want to download(image link, PDF link e.t.c)'`,
method: "GET",
responseType: "blob",
}).then((res) => {
FileDownload(res.data, 'the same file link you had input in url);
});
};
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.