简体   繁体   English

如何在react.js中包含pdf链接

[英]How to include a pdf link in react.js

i want to be able to open in a new tab a PDF i have in my include folder. 我希望能够在新标签中打开我的include文件夹中的PDF。 I'am using the create-react-app and set the link to open a new tab with the pdf, in my local it works but when i build it the tab loads as an empty page with a HTTP ERROR 404. 我正在使用create-react-app并设置链接以打开带有pdf的新选项卡,在我的本地它可以工作,但是当我构建它时,选项卡加载为带有HTTP ERROR 404的空白页面。

in my react component here is how i had it set up 在我的反应组件中,这是我如何设置它

<NavLink to={PDF} target='_blank' className='nav-link'>pdf</NavLink>

like i mentioned before in my local it works perfect but in my build it opens a 404 page. 就像我之前在我的本地提到的那样它完美无缺,但在我的构建中它打开了404页面。

like i mentioned before in my local it works perfect but in my build it opens a 404 page. 就像我之前在我的本地提到的那样它完美无缺,但在我的构建中它打开了404页面。

This is a server error. 这是服务器错误。

Find out whats wrong 找出什么是错的

  • Log the URL 记录URL
  • Check the browser console for failed web requests 检查浏览器控制台是否有失败的Web请求

Fix 固定

Once you have the URL check why there isn't a file at that URL. 一旦你有URL检查为什么该URL没有文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM