3

我创建了一个小应用程序,它接受搜索查询并返回模拟内容。您可以在此处查看该应用程序:http: //embersherpa.com/wip/search-example/app/#/search

通过搜索而不是通过 url 输入查询时,它可以正常工作。

通过 url 输入时,如何正确处理带有“/”的搜索查询?

4

1 回答 1

1

您可能不应该将关键字直接放入 URL。而是先在模型钩子中encodeURIComponent转义并取消转义。decodeURIComponent粗略的代码如下所示:

serialize : function(model){
  // model is the keyword in your case
  return {keyword: encodeURIComponent(model)};
},
model : function(params){
  var keyword = decodeURIComponent(params.keyword);
  // do what you need to do with the keyword
}
于 2013-09-26T08:41:02.853 回答