From:一条被猫抛弃的他乡流浪狗!

asp.net mvc View视图相关

1.0 @helper语法

@helper语法可以定义可重复使用的帮助器方法: 例如

@helper methodName(type paramName,...){

  //todo

}

调用:@methodName(parma)

@helper RData(int cate_id, int channel_id)
{
    var xsmsList = new ArticleService().GetDataTop(new CateModel() { cate_id = cate_id, channel_id = channel_id, haveChild = false }, 
8);//限时秒杀
    foreach (var item in xsmsList)
    {
        <li>
            <a href="#"><img src="@Keys.GetImgUrlDomainName()@item.img_url" alt=""></a>
            <h3><a href="#">@item.title</a></h3>
            <span>@item.zhaiyao</span>
            <div class="w-jiaGe cl">
                <div class="jg-left">1524人关注</div>
                <div class="jg-right">
                    <b>¥</b><strong>@item.sell_price</strong><em>起</em>
                </div>
            </div>
        </li>
    }
}

调用: @RData(7,40)

 

posted @ 2016-04-14 14:14  ICE_Inspire  阅读(539)  评论(1编辑  收藏  举报