no message

This commit is contained in:
chenxuan
2024-04-24 17:10:52 +08:00
parent 344a7ce0a9
commit 6df94d8ac7
5 changed files with 23 additions and 5 deletions
+2
View File
@@ -21,3 +21,5 @@
13、路由传参 pathname
14、push与replace
15、witchRoute 使一般组件拥有路由组件的属性,返回值是一个新组件
16、编程式路由
+1 -1
View File
@@ -8,7 +8,7 @@ import queryString from 'query-string';
import React,{Component} from 'react'
class Car extends Component{
render(){
let {search}=this.props.location
let {search}=this.props.location // search参数
const {name,id}=queryString.parse(search)
return (
<div>
+1 -1
View File
@@ -7,7 +7,7 @@
import React,{Component} from 'react'
class New extends Component{
render(){
const {name,id}=this.props.match.params
const {name,id}=this.props.match.params // params参数
console.log(this.props.match.params)
return(
<div>
+16
View File
@@ -16,6 +16,18 @@ class Header extends Component{
go=()=>{
this.props.history.go(-2)
}
push1=()=>{
this.props.history.push('/home/news/chenxuan/123')
}
push2=()=>{
this.props.history.push('/home/car?name=chenxuan&id=123456')
}
replace1=()=>{
this.props.history.replace('/home/money')
}
replace2=()=>{
this.props.history.replace('/home/money',{name:"陈轩",age:"18岁",sex:"男"})
}
render(){
return(
<div className="header">
@@ -23,6 +35,10 @@ class Header extends Component{
<button onClick={this.back}>前进</button>
<button onClick={this.forward}>后退</button>
<button onClick={this.go}>后退2步骤</button>
<button onClick={this.push1}>push1-params</button>
<button onClick={this.push2}>push2-search</button>
<button onClick={this.replace1}>replace1</button>
<button onClick={this.replace2}>replace2-state</button>
</div>
)
}