[英]How to pass parameter from URL in ReactJS?
I'm passing 2 parameters in URL 我在URL中传递了2个参数
I'm using react router to pass the properties. 我正在使用React Router传递属性。
Check the constructor: 检查构造函数:
const { match: { params } } = this.props;
I want to pass the values to async function axios fetch
; 我想将值传递给
async function axios fetch
;
async PaginationlimitPerPage (begin, end, increase) {
const _URL = "http://localhost:8888/get/material/".concat(params.categoryID,"/", params.subcategoriaID, "?page=", this.state.currentPage);
console.log(_URL);
The values params it's not passing, how to fix this? 值参数没有传递,如何解决呢?
react-router@4
does not perform parsing of querystring. react-router@4
不执行查询字符串的解析。 You can however do it yourself. 但是,您可以自己做。
Currently your are reading the path-parameters, and not querystrings. 当前,您正在读取路径参数,而不是查询字符串。
import { parse } from 'qs'
/// ----
const { location } = this.props;
const query = parse(location.search.substring(1)))
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.