【问题标题】:FlowRouter query parameter parsing is wrongFlowRouter查询参数解析错误
【发布时间】:2016-05-15 07:19:17
【问题描述】:

【问题讨论】:

    标签: meteor flow-router


    【解决方案1】:

    queryparameter中有一个key route没有任何值。所以假定的默认值是一个空字符串。它总是会返回一个具有相同名称(在本例中为“路由”)的键数组。

    所以你不会得到 route = 'torrent-item'

    previous=%2Ftorrent%3Fprevious%3D%252Fuser%26route%3D&route=torrent-item

    【讨论】:

    • 这意味着我不能将 'route=' 作为另一个查询参数的值传递
    • 你可以做任何你想做的事。但是你应该期待 route[1] = 'torrent-item'。或更改为“_route=”,这样您将获得所需的输出为“route='torrent-item'”
    • 如果我将路由放在前一个参数的前面,它可能是 route[0] = 'torrent-item'
    【解决方案2】:

    您的网址解码为

    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,那么您需要解析数组的多个参数以找到您想要的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-03-06
      • 1970-01-01
      • 1970-01-01
      • 2017-10-13
      • 1970-01-01
      • 2014-06-21
      相关资源
      最近更新 更多