我可以在jQuery模板中声明local / temp变量吗? [英] Can I declare local/temp variables within a jQuery template?
本文介绍了我可以在jQuery模板中声明local / temp变量吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在jQuery模板语法中声明新变量?我希望达到相当于这个(这不起作用):
Is it possible to declare new variables within the jQuery template syntax? I'm hoping to achieve the equivalent of this (which does not work):
{{var test = "test"}}
<div>
${test}
</div>
推荐答案
这是非常蹩脚的,但可能有效的一招是:
This is pretty lame, but one trick that might work is:
{{each(i, test) ["test"]}}
blah blah ${test} blah
{{/each}}
我不是百分百肯定然而是关于使用像这样的数组常量表达式;我会设置一个小提琴。 (编辑是的有效: - )
I'm not 100% sure however about using an array constant expression like that; I'll set up a fiddle. (edit yes it works :-)
这篇关于我可以在jQuery模板中声明local / temp变量吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文