[英]html download just says 'Failed - No file'
I know there are a plethora of questions similar to this already, but I cannot get my link to download my pdf file.我知道已经有很多类似的问题,但我无法获得下载 pdf 文件的链接。 Clicking on the link says 'Resume.pdf Failed - No file'.单击链接显示“Resume.pdf 失败 - 无文件”。 I am using React and developing locally and Dumby.js and Resume.pdf are both directly inside the src folder:我正在使用 React 并在本地进行开发,而 Dumby.js 和 Resume.pdf 都直接位于 src 文件夹中:
import React from 'react'
const Dumby = () => {
return (
<div>
<a href="./Resume.pdf" download>Resume Download</a>
</div>
)
}
export default Dumby
Something that worked for me was to import it on top.对我有用的东西是将它导入顶部。
The file is in my assets folder, and not in public:)该文件在我的资产文件夹中,而不是公开的:)
import pdf from "../assets/cv/resume.pdf";
<a
href={pdf}
className='btn'
download
rel='noopener noreferrer'
target='_blank'
>
Download cv
</a>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.