What to do if react jump routing page is blank

藏色散人
Release: 2023-01-19 13:40:31
Original
1881 people have browsed it

The react jump routing page is blank because of a writing error. The solution is: 1. Determine the link that needs to be implemented on the page; 2. Modify the code to "this.props.history.push({pathname:`/cardetails `,search:`?productId=${car.productId}`,state:car,})”.

What to do if react jump routing page is blank

The operating environment of this tutorial: Windows 10 system, react18.0.0 version, Dell G3 computer.

What should I do if the react jump routing page is blank?

react When routing parameter jumps, the page is blank

//页面需要实现的链接是这样的,http://localhost:4500/cardetails?productId=12676
 
//会导致空白的错误写法是
this.props.history.push({
                pathname:`/cardetails?productId=${car.productId}`,
                state:car,
            })
 
 
//正确写法是下面
this.props.history.push({
                pathname:`/cardetails`,
                search:`?productId=${car.productId}`,
                state:car,
            })
 
 
//以上是个人开发中遇到的问题,仅供参考~~
Copy after login

The wrong way to write it is that after the click event, the page link has changed, but the page content is blank and no error is reported. Need to Manually refresh the page to see the content. After the

writing method is changed, the routing information can be accurately located and the problem can be solved.

Recommended learning: "react video tutorial"

The above is the detailed content of What to do if react jump routing page is blank. 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