react 使用 標簽注意事項


當我嘗試使用a標簽跳轉頁面

<a href="http://baidu.com" target="_blank" ></a>

 

提示報錯:使用 target="_blank" 沒有加 rel="noopener noreferrer" 是 有安全風險的,可查看以下鏈接進行詳細查看

Using target="_blank" without rel="noopener noreferrer" is a security risk: see https://mathiasbynens.github.io/rel-noopener

 

 修改方法:

一、在a標簽上加上 rel="noopener noreferrer"

<a href="http://baidu.com" target="_blank" rel="noopener noreferrer"></a>

  

二、使用div標簽

<div onClick={() => {window.open('http://baidu.com')}}></div>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM