gpt4 book ai didi

javascript - 无法在本地 react 应用程序中下载pdf

转载 作者:行者123 更新时间:2023-12-03 01:31:17 37 4
gpt4 key购买 nike

I am creating a portfolio using reactjs , Unable to download the resume pdf file on clicking . I get message as no file.

Here is my Resume component

import React, { Component } from 'react';
import './Resume.css';
import resume from '../doc/ResumeAbhishek.pdf';

class Resume extends Component {
render() {
return (
<div>
<div className="row">
<div className="col">
<center>RESUME DOWNLOAD</center>
</div>
</div>
<br />
<div className="row">
<div className="col">
<center>
<a type="button" className="btn btn-secondary btn-lg"
href={resume}
download="ResumeAbhishek.pdf">
<i class="fa fa-download" aria-hidden="true" />
&nbsp; Resume</a>
</center>
</div>
</div>
</div>
);
}
}

export default Resume;

最佳答案

为什么要从 pdf 导入?您的 href 应该是文件的路径,类似这样的内容应该有效:

 <a type="button" 
className="btn btn-secondary btn-lg"
href='/path/to/ResumeAbhishek.pdf'
download>
</a>

关于javascript - 无法在本地 react 应用程序中下载pdf,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51287808/

37 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com