简体   繁体   中英

React Link to - provide absolute path

I have below code

<Link className={classes.btnText}  key= {props.id} 
                to= {"https://s3.amazonaws.com/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.com/pdf/download.pdf

Can i know how to give complete url

您可以使用<a>标签代替

<a href="https://s3.amazonaws.com/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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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