There was an error while loading. Please reload this page.
foreach 结构的主要职能是装逼,装得好像foreach循环我也有一样,其实它的职能早就通过element的datapath实现过了,副作用是可以改善一点模板代码的可读性。
{ foreach: Array|数据漫游器|取值函数, t: 行模板 }
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <script src="../jquery.js"></script> <script src="../thin.js"></script> <title>Document</title> </head> <body> <container></container> <script> $(function() { var data = { title: "foreach test", items: [{ f1: "row1", f2: "row1f2" }, { f1: "row2", f2: "row2f2" }] } $("container").render({ data: data, template: { e: "fieldset", title: "[[title]]", t: { foreach: "items", t: { e: "li", t: "[[f1]]:[[f2]]" } } } }); }); </script> </body> </html>