Home  >  Article  >  Web Front-end  >  How to click to jump in react

How to click to jump in react

coldplay.xixi
coldplay.xixiOriginal
2020-12-21 11:29:344642browse

How to click to jump to a new page in react: 1. Click on the local page to open a new page and introduce the ant Button component; 2. The local page will jump to the new page unchanged.

How to click to jump in react

The operating environment of this tutorial: windows7 system, React17 version. This method is suitable for all brands of computers.

Related learning recommendations: react video tutorial

How to click to jump to a new page in react:

(1) Click the local page to open a new page

Introduce ant's Button component

<Button style={{backgroundColor:&#39;#F0F2F5&#39;}}
  onClick={()=>{window.location.href="https://baidu.com"}}
  className="r-button"
>

Introduceimport {Link} from 'react-router-dom '

<Link to="/new/login/">
<Button className="e-button" type="primary">Back to login page</Button>
</Link>

(2). Jump to the new page without changing the local page

<Button style={{backgroundColor:&#39;#F0F2F5&#39;}}
onClick={this.handle}
className="last-button"
>
handle=()=>{
  const w=window.open(&#39;about:blank&#39;);
  w.location.href="www.baidu.com"
}

Related learning recommendations: javascript video Tutorial

The above is the detailed content of How to click to jump in react. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn