亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

BaiduTemplate模板引擎使用示例(附源碼)

 更新時(shí)間:2016年12月22日 16:29:02   作者:Chevin  
本文主要分享了BaiduTemplate模板引擎使用示例,具有很好的參考價(jià)值,需要的朋友一起來看下吧

1、新建項(xiàng)目,asp.net 空Web應(yīng)用程序

添加data,js,styles,templates文件夾,添加baiduTemplate.js,jquery.js,bootstrap.css

2、添加list.js腳本,代碼如下

var data = {
 "list": [
 {
 "col1": "行1",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行2",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行3",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行4",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行5",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行6",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行7",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 },
 {
 "col1": "行8",
 "col2": "數(shù)據(jù)2",
 "col3": "數(shù)據(jù)3",
 "col4": "數(shù)據(jù)6",
 "col5": "數(shù)據(jù)5",
 "col6": "數(shù)據(jù)6"
 }
 ]
};
var template = "templates/list.html";
$.ajax({
 url: template,
 dataType: "html",
 success: function (val) {
 $("#list").html(baidu.template(val, data));
 }
});

添加模板文件list.html,內(nèi)容如下

<table class="table table-bordered">
 <thead>
 <tr>
 <td>列1</td>
 <td>列2</td>
 <td>列3</td>
 <td>列4</td>
 <td>列5</td>
 <td>列6</td>
 </tr>
 </thead>
 <%for(var i = 0; i<list.length;i++){ var item=list[i];%>
 <tr>
 <td><%=item.col1%></td>
 <td><%=item.col2%></td>
 <td><%=item.col3%></td>
 <td><%=item.col4%></td>
 <td><%=item.col5%></td>
 <td><%=item.col6%></td>
 </tr>
 <%}%>
</table>

3、添加default.aspx頁面,并添加引用

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="baiduTemplate.Default" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
 <title></title>
 <script src="js/jquery.min.js"></script>
 <script src="js/baiduTemplate.js"></script>
 <script src="js/list.js"></script>
 <link href="styles/bootstrap.css" rel="stylesheet" />
</head>
<body>
 <form id="form1" runat="server">
 <div id="list" style="margin-top:10px;">
 </div>
 </form>
</body>
</html>

預(yù)覽效果:

源碼下載http://xiazai.jb51.net/201612/yuanma/baiduTemplate_jb51.rar

以上就是本文的全部內(nèi)容,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,同時(shí)也希望多多支持腳本之家!

相關(guān)文章

  • ASP.NET MVC5網(wǎng)站開發(fā)我的咨詢列表及添加咨詢(十二)

    ASP.NET MVC5網(wǎng)站開發(fā)我的咨詢列表及添加咨詢(十二)

    這篇文章主要為大家詳細(xì)介紹了ASP.NET MVC5網(wǎng)站開發(fā)我的咨詢列表及添加咨詢,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2015-09-09
  • ASP.net 路徑問題 詳解

    ASP.net 路徑問題 詳解

    各位有沒有碰到在日常工作中經(jīng)常在路徑設(shè)置的時(shí)候把 "~/ 、./ 、../ 、 / 、"這些符號搞混搞亂了?
    2010-05-05
  • .Net WebApi消息攔截器之MessageHandler的示例

    .Net WebApi消息攔截器之MessageHandler的示例

    這篇文章主要介紹了.Net WebApi消息攔截器之MessageHandler的示例,小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2018-08-08
  • asp.net(c#) ubb處理類

    asp.net(c#) ubb處理類

    asp.net下對于編輯器中的ubb進(jìn)行替換處理的實(shí)現(xiàn)代碼
    2008-08-08
  • 如何使用Python實(shí)現(xiàn)阿拉伯?dāng)?shù)字轉(zhuǎn)換成中國漢字

    如何使用Python實(shí)現(xiàn)阿拉伯?dāng)?shù)字轉(zhuǎn)換成中國漢字

    本文提供了一個(gè)Python代碼示例,用于將阿拉伯?dāng)?shù)字轉(zhuǎn)換為中文漢字表示,代碼定義了數(shù)字到漢字的映射表,并實(shí)現(xiàn)了處理不同位數(shù)(如個(gè)、十、百、千、萬等)的函數(shù),特別地,處理方式包括對大數(shù)字的分解和轉(zhuǎn)換,以及對連續(xù)零的特殊處理,感興趣的朋友跟隨小編一起看看吧
    2024-09-09
  • 聊一聊Asp.net過濾器Filter那一些事

    聊一聊Asp.net過濾器Filter那一些事

    這篇文章主要介紹了聊一聊Asp.net過濾器Filter那一些事,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-06-06
  • .Net獲取IP地址的方法

    .Net獲取IP地址的方法

    這篇文章主要介紹了.Net獲取IP地址的方法,本文給大家介紹的非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-01-01
  • AspNetPager與Socut.Data使用實(shí)例代碼

    AspNetPager與Socut.Data使用實(shí)例代碼

    最近對AspNetPager與Socut.Data這兩個(gè)控件產(chǎn)生了濃厚的興趣,這兩個(gè)控件配合可以減輕很多程序員編寫代碼的壓力。ASpNetPager為分頁控件,而Socut.Data為數(shù)據(jù)操作控件,ACCESS,MSSQL都可以。
    2008-07-07
  • VS2010制作第一個(gè)簡單網(wǎng)站

    VS2010制作第一個(gè)簡單網(wǎng)站

    這篇文章主要為大家介紹VS2010如何制作第一個(gè)簡單網(wǎng)站,和大家一起學(xué)習(xí) 動(dòng)態(tài)網(wǎng)站開發(fā)技術(shù),感興趣的小伙伴們可以參考一下
    2015-11-11
  • 在.NET中使用Newtonsoft.Json轉(zhuǎn)換,讀取,寫入的方法介紹

    在.NET中使用Newtonsoft.Json轉(zhuǎn)換,讀取,寫入的方法介紹

    Newtonsoft.Json.JsonConvert類是非微軟提供的一個(gè)JSON序列化和反序列的開源免費(fèi)的類庫
    2012-08-08

最新評論