我看到人们建议每当在链接中使用target ="blank"在另一个窗口中打开它时,她应该放置rel ="noopener noreferrer".我想知道这是如何阻止我在Chrome中使用开发者工具,以及删除rel属性的.然后点击链接......
这仍然是保持漏洞的简单方法吗?
如果我总是重定向到应用内路由,那么Redirectreact-router-dom(v4)中的组件和this.props.history.push()?之间的区别是什么?
例如,假设我希望用户给定的标题添加到URL和重定向/foo/123到/foo/123/some-title(均含有相同的路线/组件渲染).
我看到了Redirect传递状态的一些用途.这到底在哪里?
是否为反模式指定要在状态中重定向到的位置?为什么示例代码看起来不像这样:
save() {
this.setState({ redir: '/new-path'; });
}
...
render () {
if (this.state.redir) {
return <Redirect to={this.state.redir} />;
}
...
}
Run Code Online (Sandbox Code Playgroud) 我理解的 href 和 link 之间的区别。
但是我想知道使用link和withrouter和history.push的区别?如果我已经访问过该页面,history.push 会检索缓存中的页面吗?
使用链接:
<Link className="btn btn-primary" onClick={logout} to="/">
Log out
</Link>
Run Code Online (Sandbox Code Playgroud)
使用历史:
constructor(props) {
super(props);
this.handleLogout = this.handleLogout.bind(this);
};
handleLogout(e) {
const { history } = this.props;
logout()
history.push("/");
}
<button type="button" onClick={this.handleLogout}>Log out</button>
Run Code Online (Sandbox Code Playgroud)