相关疑难解决方法(0)

与target ="_ blank"和rel ="noopener noreferrer"的链接仍然很脆弱?

我看到人们建议每当在链接中使用target ="blank"在另一个窗口中打开它时,她应该放置rel ="noopener noreferrer".我想知道这是如何阻止我在Chrome中使用开发者工具,以及删除rel属性的.然后点击链接......

这仍然是保持漏洞的简单方法吗?

html

46
推荐指数
5
解决办法
2万
查看次数

在React中渲染Redirect总是比使用this.props.history.push更好吗?

如果我总是重定向到应用内路由,那么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)

redirect reactjs react-router

7
推荐指数
1
解决办法
3605
查看次数

react-router-dom - 链接和 history.push 之间的区别?

我理解的 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)

reactjs react-router react-router-v4 react-router-dom

5
推荐指数
1
解决办法
4908
查看次数