簡體   English   中英

如何從ReactJS中的URL傳遞參數?

[英]How to pass parameter from URL in ReactJS?

我在URL中傳遞了2個參數

我正在使用React Router傳遞屬性。

檢查構造函數:

 const { match: { params } } = this.props;

我想將值傳遞給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);

值參數沒有傳遞,如何解決呢?

react-router@4不執行查詢字符串的解析。 但是,您可以自己做。

當前,您正在讀取路徑參數,而不是查詢字符串。

import { parse } from 'qs'

/// ----

const { location } = this.props;
const query = parse(location.search.substring(1)))

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM