Kendo UI 编码模板符号似乎不起作用
Kendo UI Template notation for encoding doesn't seem to work
根据 Kendo UI template documentation,您可以使用 #=Field#
或 #:Field#
表示法,并使用 #:Field#
表示法对文本进行编码。但是,我似乎无法让它工作。
我在我的模型中创建了一个字段,它只返回一个字符串,<b>Todd</b>
。然后,我使用了这样的模板:
<a href="/page.aspx?path=#=Field#"></a>
还有这样的:
<a href="/page.aspx?path=#:Field#"></a>
在这两种情况下,输出都是
<a href="/page.aspx?path=<b>Todd<b>"></a>
虽然我期望#=Field# 符号,但对于#:Field# 符号,我期望:
<a href="/page.aspx?path=%3Cb%3ETodd%3C/b%3E"></a>
关于为什么这不像我期望的那样工作有什么想法吗?
收到 Kendo 的回复。他们说使用#:encodeURI(Field)#、#:encodeURIComponent(Field)# 或#:escape(Field)# 而不是#:Field# 来获得我正在寻找的结果。
我测试了一下,它对我有用。
根据 Kendo UI template documentation,您可以使用 #=Field#
或 #:Field#
表示法,并使用 #:Field#
表示法对文本进行编码。但是,我似乎无法让它工作。
我在我的模型中创建了一个字段,它只返回一个字符串,<b>Todd</b>
。然后,我使用了这样的模板:
<a href="/page.aspx?path=#=Field#"></a>
还有这样的:
<a href="/page.aspx?path=#:Field#"></a>
在这两种情况下,输出都是
<a href="/page.aspx?path=<b>Todd<b>"></a>
虽然我期望#=Field# 符号,但对于#:Field# 符号,我期望:
<a href="/page.aspx?path=%3Cb%3ETodd%3C/b%3E"></a>
关于为什么这不像我期望的那样工作有什么想法吗?
收到 Kendo 的回复。他们说使用#:encodeURI(Field)#、#:encodeURIComponent(Field)# 或#:escape(Field)# 而不是#:Field# 来获得我正在寻找的结果。
我测试了一下,它对我有用。