最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - React Link to - provide absolute path - Stack Overflow

programmeradmin1浏览0评论

I have below code

<Link className={classes.btnText}  key= {props.id} 
                to= {".pdf" } target="_blank" download>Brochure <span> &darr; </span> </Link>

The issue is i'm not able to give the absolute path. It is getting updated as

localhost:3000/.pdf

Can i know how to give plete url

I have below code

<Link className={classes.btnText}  key= {props.id} 
                to= {"https://s3.amazonaws./pdf/download.pdf" } target="_blank" download>Brochure <span> &darr; </span> </Link>

The issue is i'm not able to give the absolute path. It is getting updated as

localhost:3000/https://s3.amazonaws./pdf/download.pdf

Can i know how to give plete url

Share Improve this question asked Oct 12, 2020 at 9:43 upogupog 5,5468 gold badges55 silver badges86 bronze badges 1
  • 2 Link is for "pages" in your router, if you want to send the user somewhere else use a regular a. – jonrsharpe Commented Oct 12, 2020 at 9:46
Add a ment  | 

3 Answers 3

Reset to default 5

You can use <a> tag instead

<a href="https://s3.amazonaws./pdf/download.pdf" target="_blank" className={classes.btnText}>

That's how the {Link} works :)

Maybe use <a> tag instead ?

Yeah because Link builds all the routes from your home/root path which is localhost:3000 in local dev environment. So that's why its appending to that.

use hyperlink tag <a> instead

发布评论

评论列表(0)

  1. 暂无评论