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

I have below code<Link className={classes.btnText}key= {props.id} to= {".pdf" } target=

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745090528a4610667.html

相关推荐

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

    I have below code<Link className={classes.btnText}key= {props.id} to= {".pdf" } target=

    16小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信