将示例文件下载到公用文件夹中(反应) [英] download sample file in public folder (react)

查看:60
本文介绍了将示例文件下载到公用文件夹中(反应)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在公共文件夹(反应项目)中放置一个样本xlsx文件,其他人可以下载此文件。

I want to put a sample xlsx file in my public folder (react project) and others can download this file.

<Button><link rel="chargeSample" href="%PUBLIC_URL%/chargeSample.xlsx"></link></Button>

我该怎么做?

推荐答案

标签定义文档和外部资源之间的链接。
要在您的网站上下载功能,您应该更改链接标记

The tag defines a link between a document and an external resource. To let download funcionality on your website you should change link tag

import chargeSample from './public/chargeSample.xlsx';

<Button><a href={chargeSample} download="your file name">Download</a></Button>

这篇关于将示例文件下载到公用文件夹中(反应)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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