Home > Web Front-end > JS Tutorial > body text

How to click to jump in react

coldplay.xixi
Release: 2020-12-21 11:29:34
Original
4689 people have browsed it

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"
>
Copy after login

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

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

(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"
}
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template