2017-04-06 63 views

回答

0

至少在这里与lodash做一个很短的方式:

const getQuery =() => { 
    let qp = new URLSearchParams(location.search) 
    _.fromPairs([...qp.entries()]) 
} 

哦,现在,在提交我看到:How to parse query string in react-router v4,但我的回答获得了整个对象。

+0

注意URLSearchParams尚未得到广泛支持,例如,在边缘。请参阅http://caniuse.com/#feat=urlsearchparams –