简单的问题。
例如,当我在/dashboard路由器中并单击<Link to="/users/:userID" >路由器并尝试返回/dashboard它时,wine 可以正常工作,但是当/users/:userID我从路由器导航到另一个/users/:userID路由器并尝试返回时,我需要单击后退按钮两次,不知道为什么?
例如
/dashboard -> /users/1 并返回(需要 1 次点击)
/dashboard -> /users/1 -> /users/2 并返回到 /users/1(需要点击 2 次)
这是我在 App.js 中的路线
<Route path='/users/:userId' render={()=><User/>} />
Run Code Online (Sandbox Code Playgroud)
这是我的 User.jsx render()
render() {
let movie = this.props.thisUserIdData;
const { match } = this.props;
console.log(match);
return (
<div> .... </div>
)
}
Run Code Online (Sandbox Code Playgroud)
和 componentDidMount()
componentDidMount() {
this.loadData(this.props.match.params.userId);
//using redux and axios to get data
}
Run Code Online (Sandbox Code Playgroud) 我有这个组件状态
this.state = {
title: "",
salary: {
min: "",
max: "",
single: ""
}
}
Run Code Online (Sandbox Code Playgroud)
我使用这个函数来处理用户输入
handleInputChange = (e) => {
this.setState({[e.target.name]:e.target.value});
}
Run Code Online (Sandbox Code Playgroud)
它与
<input type="text" id="title" name="title" onChange={this.handleInputChange}/>
Run Code Online (Sandbox Code Playgroud)
我可以用这样的函数来改变 this.state.salary.min/max ...
我的意思是这种类型的函数可以与 state 中的嵌套对象一起使用<input/> name art吗?