【发布时间】:2022-11-10 00:53:00
【问题描述】:
我使用 ReactJS 开发了一个 UI,路由器版本是 6。
我在 ReactJS 中使用了以下路由来传递我的参数,但我无法在类端获取参数,它给出的匹配错误未定义。
路由文件
<Route exact path="/productcategory/:category" element={<ProductCategoryPage />} />
产品类别页面文件
export class ProductCategoryPage extends Component {
constructor({match}){
super();
this.state = {
Category: match.params.category,
ProductData: []
}
}
render () {
UI codes goes here.
}
}
错误是匹配未定义
【问题讨论】:
标签: reactjs react-router