我不知道我错在哪里。我想将该参数作为状态传递给 Link 标记并在另一个组件中获取它。
import React from 'react'
import {Link} from "react-router-dom";
export default class CategoryList extends React.Component{
render(){
return(
<tr>
<td>
<Link to={{pathname:"/Topics/" + this.props.row.Occupation+"/"+this.props.row.objectId +'/id'+'/'+this.props.userName, state:{description:this.props.row.Description}}}>
{this.props.row.Occupation}
</Link>
</td>
<td>{this.props.row.Description}</td>
</tr>
)
}
}
Run Code Online (Sandbox Code Playgroud)
索引.js
<Route path="/Topics/:Occupation/:objectId/:id/:userName" component={Main} />
Run Code Online (Sandbox Code Playgroud)
我想在这里传递它并访问 Link 标签中给出的状态。所以你的帮助会很大。