當我試圖解析此網址:FlowRouter查詢參數解析是錯誤的
我期待route = 'torrent-item'
(字符串),但FlowRouter路由器值["", "torrent-item"]
(陣列)
回購 - https://github.com/HedCET/TorrentSearch
當我試圖解析此網址:FlowRouter查詢參數解析是錯誤的
我期待route = 'torrent-item'
(字符串),但FlowRouter路由器值["", "torrent-item"]
(陣列)
回購 - https://github.com/HedCET/TorrentSearch
有一個關鍵路由在queryparameter沒有價值。所以默認值是一個空字符串。它總是會返回一組相同的密鑰,名稱(在本例中爲'路由')。
所以,你不會得到路線= '洪流項目'
以往=%2Ftorrent%3Fprevious%3D%252Fuser%26 路線%3D &路線=洪流項
你URL解碼爲
http://localhost:3000/torrent?previous=/torrent?previous=%2Fuser&route=&route=torrent-item
CF:http://meyerweb.com/eric/tools/dencoder/
所以你有&route=&route=torrent-item
這將返回["", "torrent-item"]
因爲路線有兩次。
你只需要計算如何正確編碼這個URL來正確讀取它。
如果是從某處讀取的URL,則需要解析數組的多個參數以查找所需內容。
這意味着我不能通過'route ='作爲另一個查詢參數的值 –
你可以做任何你想做的事情。但是你應該期望route [1] ='torrent-item'。或更改爲「_route =」,所以你會得到你想要的輸出爲「route ='torrent-item'」 –
它可能是路由[0] ='torrent-item'如果我把前一參數的路線infront –