Getting query parameters from react-router hash fragment

后端 未结 9 1565
心在旅途
心在旅途 2020-12-04 11:55

I\'m using react and react-router for my application on the client side. I can\'t seem to figure out how to get the following query parameters from a url like:



        
9条回答
  •  春和景丽
    2020-12-04 12:20

    "react-router-dom": "^5.0.0",
    

    you do not need to add any additional module just in your component that has a url address like this:

    http://localhost:3000/#/?authority'

    you can try the following simple code:

        const search =this.props.location.search;
        const params = new URLSearchParams(search);
        const authority = params.get('authority'); //
    

提交回复
热议问题