gpt4 book ai didi

ember.js - 如何处理 Ember.js 应用程序中包含 "/"的搜索查询?

转载 作者:行者123 更新时间:2023-12-02 20:17:28 24 4
gpt4 key购买 nike

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

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

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

最佳答案

您可能不应该将关键字直接放入网址中。相反,首先使用 encodeURIComponent 对其进行转义,然后在模型 Hook 中使用 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
}

关于ember.js - 如何处理 Ember.js 应用程序中包含 "/"的搜索查询?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18960472/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com