【问题标题】:open external URL but opens localhost:3000/www.google.com [closed]打开外部 URL 但打开 localhost:3000/www.google.com [关闭]
【发布时间】:2022-01-03 23:05:42
【问题描述】:

我正在尝试打开一个外部 URL,但不是在新选项卡中打开 www.google.com,而是打开 http://localhost:3001/www.google.com

<IconButton key={index} size="large" color="primary" href={e.url} target={"_blank"} aria-label="menu" style={{zIndex:100}} >
 <img style={{width:'30px', height:'30px', maxHeight:'30px', maxWidth:'30px'}} href={e.url} target="_blank"
   src={icon}/>
   </IconButton>

【问题讨论】:

    标签: javascript html css reactjs location-href


    【解决方案1】:

    尝试将“https://”添加到 URL 的开头以使其成为绝对 URL - 否则它会认为这是相对于当前 URL 的链接。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-17
      相关资源
      最近更新 更多