1. a标签跳转 eslint 提示错误
标签上添加:rel="noopener noreferrer"
<a href="xxx" className="btn-tip" target="_blank" rel="noopener noreferrer">
<Icon type="question-circle"/>
</a>
参考:https://mathiasbynens.github.io/rel-noopener/
2.避免Can only update a mounted or mounting component问题
componentWillUnmount(){
//重写组件的setState方法,直接返回空 避免Can only update a mounted or mounting component问题
this.setState = ()=>{
return;
};
}
本文介绍了解决a标签使用时ESLint报错的方法,通过添加rel属性避免安全问题,并提供了一个避免React组件卸载后仍尝试更新状态导致错误的解决方案。

2万+

被折叠的 条评论
为什么被折叠?



