文档地址:https://aui.github.io/art-template/zh-cn/docs/syntax.html
参考博客:https://blog.csdn.net/gao_xu_520/article/details/78594792
参考博客:https://blog.csdn.net/qq_33401924/article/details/53259631
在模板中运用三元运算符
<b class="fl {
{v.MatchWin==1?'win':''}}">{
{v.ScoreA}}</b>
在模板中的 if elseif 语法的运用
{
{if v.MatchStatus == 1}}
<em>未开始</em>
{
{else if v.MatchStatus == 2}}
<em>进行中</em>
{
{else}}
<em>已结束</em>
{
{if}}
在模板中template.helper, 用来处理模板中参数的函数
第一种情况:
//这里的script的id对应下面template的渲染区域,并且type必须是text/html注:1.这里的 {
{each result as value i}} ,i也可以写成index,代表索引号; value是每一项是value;
2. {
{#value.img}},这种前面加#号的,表示 不编码输出,例这里这样写是因为后台取回来的img是含有img标签的了,所以直接输出就可以,不需要编码
$(function () {
$.ajax({
url:‘http://192.168.16.27:9090/api/getindexmenu’,
type:‘get’,
dataType:‘json’,
success:function (result) {
var html= template(‘template’,result);//这里的 template(‘template’,result)对应2步的script的id
console.log(result);
$(’#content’).append(html);//写法1
document.getElementById(“content”).innerHTML = html;// 写法2
}
})
});
第二种情况:
另一种情况,当取回来的数据是多组对象的形式,如下:(跟上面的对比就是一组数据跟多组数据)
var data={
0:{iNewsId: “1”, sTitle: “哈哈哈1”, iFrom: “22334”, sGameVersion: “”, sAuthor: “奇迹”},
1:{iNewsId