我想添加 </br>
XTemplate
中 12 次迭代后。我尝试了很多方法,但无法使其发挥作用。示例代码如下:
days = new Ext.XTemplate(
'<b>Days of month</b>',
'<table width="100%"><tr><td style="word-wrap:break-word;">',
'<tpl for=".">',
'<tpl for="data">',
**'{% if (xindex % 12 === 0) { %}' +
'<br/>' +
'{% } %}',**
,'{fieldValue}',
'</tpl>',
'</tpl>',
'</td></tr></table>',
我尝试使用xindex
,但没有任何效果,并且在 12 条记录后不添加换行符。我做错了什么?
最佳答案
完整示例:
Ext.onReady(function() {
var data = [1, 2, 3, 4, 5, 6];
var tpl = new Ext.XTemplate([
'<tpl for=".">',
'{.}',
'<tpl if="xindex % 2 === 0"><br /></tpl>',
'</tpl>'
]);
tpl.overwrite(Ext.getBody(), data);
});
关于javascript - 如何使用 XTemplate 在 x 次迭代后添加换行符(换行符)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18370102/