标签:range ide clear success onclick ogre list ogr str
首先,先写自定义的方法:
function (sex) { var Max = 2; var Min = 1; var Range = Max - Min; var Rand = Math.random(); var res = (Min + Math.round(Rand * Range)); if (sex == ‘女‘) { res = res + 2; } return res; }
然后,在juicer里注册这个方法。
juicer.register(‘rand‘, app.rand);
最后,在模板里使用这个方法:
{@each list as it,k} {@if k < 10} <li class="{@if k > 3} hide {@/if}"> <div class="city-head"> <img src="images/touxiang${it.sex|rand}.png" alt="" /> </div> <div class="city-process"> <div class="city-name"> ${it.name} ${it.tel} </div> <div class="progress progress-striped"> <div class="progress-bar progress-bar-info" role="progressbar progress-bar-success" aria-valuenow="${it.scale}" aria-valuemin="0" aria-valuemax="100" style="width: ${it.scale}%"></div> </div> </div> <div class="city-km"> ${it.distance}km </div> <div class="clearfix"></div> </li> {@/if} {@/each} <li> <div id="citymore" class="more hidecity" onclick="app.showMoreCitys();">更多详细信息<i class="icon icon-chevron-down"></i></div> </li>
标签:range ide clear success onclick ogre list ogr str
原文地址:http://www.cnblogs.com/wpcnblog/p/7568266.html