【发布时间】:2016-05-15 07:19:17
【问题描述】:
当我试图解析这个 URL 时:
我期待 route = 'torrent-item'(字符串),但 FlowRouter 路由器值是 ["", "torrent-item"](数组)
【问题讨论】:
标签: meteor flow-router
当我试图解析这个 URL 时:
我期待 route = 'torrent-item'(字符串),但 FlowRouter 路由器值是 ["", "torrent-item"](数组)
【问题讨论】:
标签: meteor flow-router
queryparameter中有一个key route没有任何值。所以假定的默认值是一个空字符串。它总是会返回一个具有相同名称(在本例中为“路由”)的键数组。
所以你不会得到 route = 'torrent-item'
previous=%2Ftorrent%3Fprevious%3D%252Fuser%26route%3D&route=torrent-item
【讨论】:
您的网址解码为
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,那么您需要解析数组的多个参数以找到您想要的。
【讨论】: