我有一個奇怪的UI5問題。我創建控件的綁定上下文,它看起來像一個字符串:「%」正在獲取URI解碼,而其他所有不是
Entity('Element%3AInfo%2CID')
只是爲了信息,它看起來像這樣解碼:Entity('Element:Info,ID')
不過,我從下面的方法鏈這個字符串:
oItem.getBindingContext().getPath().substr(1)
所以,整個(非常基本的) 「導航到」 塊看起來是這樣的:
showElement : function (oItem) {
'use strict';
var bReplace = jQuery.device.is.phone ? false : true;
sap.ui.core.UIComponent.getRouterFor(this).navTo("element", {
from: "master",
element: oItem.getBindingContext().getPath().substr(1),
otherpattern: "something"
}, bReplace);
},
此塊console.log(oItem.getBindingContext().getPath().substr(1));
中的控制檯日誌提供了正確的字符串。
控制檯的console.log的輸出(oItem.getBindingContext()的getPath()SUBSTR(1)。): 實體( '元素%3AInfo%2CID')
的問題是(要知道,這是越來越好奇),我的URL模式 「{element}
」 充滿了:
Entity('Element%253AInfo%252CID')
解碼:Entity('Element%3AInfo%2CID')
由於你可能已經知道,模式的「%」是編碼的。我不明白爲什麼UI5會這樣做。
你也應該知道這些事實,我測試過:
decodeURIComponent(oItem.getBindingContext().getPath().substr(1))
導致 「Entity('Element:Info,ID')
」encodeURIComponent(oItem.getBindingContext().getPath().substr(1))
導致 「Entity('Element%25253AInfo%25252CID')
」oItem.getBindingContext().getPath().substr(1).replace("%3A", ":")
導致 「Entity('Element:Info%252CID')
」
這是一個錯誤?我的意思是隻要沒有達到「%」,URI模式就保持不變。 由於某些奇怪的原因,這個特殊字符被編碼,而其他一切都不重要。
我的直覺是庫需要一個解碼的字符串。 – royhowie
@royhowie完全解碼的字符串(請參見第一個列表項)不適合,因爲我需要像這樣的實體('Element%3AInfo%2CID')字符串 – OddDev