簡體   English   中英

帶有“ =”字符的Ember QueryParams

[英]Ember QueryParams with “=” character

我在這里有一個相對簡單的問題,但找不到解決方案。 我正在使用Ember並使用查詢參數調用路由。 代碼如下。

從“ ember”導入Ember;

export default Ember.ObjectController.extend({
    queryParams : ['user_id','custom_lis_person_name_given']
    user_id : null,
    custom_lis_person_name_given : null
});

現在,假設我要使用以下網址調用我的路線,

localhost:4200/index.html#/route1?user_id=123456&custom_lis_person_name_given=hello

現在查詢參數的值是

user_id = 123456
custom_lis_person_name_given = hello

現在,如果我將網址更改為

localhost:4200/index.html#/route1?user_id=12345=6&custom_lis_person_name_given=hello
localhost:4200/index.html#/route1?user_id=123456=&custom_lis_person_name_given=hello

現在值計算為

user_id = 12345 or user_id=123456
custom_lis_person_name_given = hello

因此,該值基本上在查詢參數值中看到=符號的地方結束。 這有解決方法嗎? 我需要user_id = “ 12345 = 6”“ 123456 =”

也許控制器或路由中有一些鈎子可以做到這一點。 我嘗試了serializeQueryParamdeserializeQueryParam,但沒有幫助。

提前致謝

你有沒有嘗試過:

encodeURIComponent(url)

那應該做的工作。 請注意,您仍然必須對=符號進行編碼,因此它應該是正確的。

encdeURIencodeURIComponent之間的區別在這里得到了很好的描述: 我應該使用encodeURI還是encodeURIComponent對URL進行編碼? 在接受的答案中。

編輯:

如果要手動編輯鏈接並檢查鏈接是否可用,只需將%3D = %3D替換為encodeURIComponent("=")

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM