react獲取當前頁面的url參數,必須在url路由對應的組件上獲取,在子組件上獲取不到,爲undefined,獲取形如 /news/:id 的後面的參數 id
this.props.match.params.id
獲取形如 /news?id="abc"的 ?id="abc" 部分,
this.props.location.search
react獲取當前頁面的url參數,必須在url路由對應的組件上獲取,在子組件上獲取不到,爲undefined,獲取形如 /news/:id 的後面的參數 id
this.props.match.params.id
獲取形如 /news?id="abc"的 ?id="abc" 部分,
this.props.location.search