這篇文章給大家介紹如何使用BaiduTemplate模板引擎,內(nèi)容非常詳細(xì),感興趣的小伙伴們可以參考借鑒,希望對大家能有所幫助。
成都創(chuàng)新互聯(lián)公司主要從事成都網(wǎng)站設(shè)計、做網(wǎng)站、網(wǎng)頁設(shè)計、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)晉安,十載網(wǎng)站建設(shè)經(jīng)驗,價格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):028-869222201、新建項目,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)容如下
列1 | 列2 | 列3 | 列4 | 列5 | 列6 |
<%=item.col1%> | <%=item.col2%> | <%=item.col3%> | <%=item.col4%> | <%=item.col5%> | <%=item.col6%> |
3、添加default.aspx頁面,并添加引用
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="baiduTemplate.Default" %>
預(yù)覽效果:
關(guān)于如何使用BaiduTemplate模板引擎就分享到這里了,希望以上內(nèi)容可以對大家有一定的幫助,可以學(xué)到更多知識。如果覺得文章不錯,可以把它分享出去讓更多的人看到。