react 使用<a> 标签注意事项

当我尝试使用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>
原文地址:https://www.cnblogs.com/gqx-html/p/13801448.html