layui table模塊中如何使用前提參數(shù)?后端開發(fā)
導(dǎo)讀:后端開發(fā)后端開發(fā)layui的table模塊是一個(gè)重頭,在基礎(chǔ)參數(shù)方面盡可能地做到友好,即:保證功">
layui 的 table模塊是一個(gè)重頭,在基礎(chǔ)參數(shù)方面盡可能地做到友好,即:保證功能的前提而又避免過于繁雜的配置。基礎(chǔ)參數(shù)一般出現(xiàn)在以下幾種場(chǎng)景中:
場(chǎng)景一:下述 lay-data 里面的內(nèi)容即為基礎(chǔ)參數(shù)項(xiàng),切記:值要用單引號(hào) <table lay-data="{height:300, url:'/api/data'}" lay-filter="demo"> …… </table> 場(chǎng)景二:下述方法中的鍵值即為基礎(chǔ)參數(shù)項(xiàng) table.render({ height: 300 ,url: '/api/data' }); 更多場(chǎng)景:下述options即為含有基礎(chǔ)參數(shù)項(xiàng)的對(duì)象 > table.init('filter', options); //轉(zhuǎn)化靜態(tài)表格 > var tableObj = table.render({}); tableObj.reload(options); //重載表格接下來看一下基礎(chǔ)元素有哪些?
1、elem - 綁定元素是指定原始table容器,只適用于 table.render()的渲染方式
HTML: <table id="test"></table> JS: table.render({ //其它參數(shù)在此省略 elem: '#test' //或 elem: document.getElementById('test') 等 });2、設(shè)置表頭,這里包含很多值,是一個(gè)二維數(shù)組。如果你采用表格的“方法級(jí)渲染”,那么你需要借助該參數(shù)來設(shè)定表格。如:
JS: table.render({ cols: [[ //標(biāo)題欄 {checkbox: true} ,{field: 'id', title: 'ID', width: 80} ,{field: 'username', title: '用戶名', width: 120} ]] }); 它等價(jià)于: <table class="layui-table" lay-data="{基礎(chǔ)參數(shù)}" lay-filter="test"> <thead> <tr> <th lay-data="{checkbox:true}"></th> <th lay-data="{field:'id', width:80}">ID</th> <th lay-data="{field:'username', width:180}">用戶名</th> </tr> </thead> </table>下面是一個(gè)二級(jí)表頭的例子:
JS: table.render({ cols: [[ //標(biāo)題欄 {field: 'username', title: '聯(lián)系人', width: 80, rowspan: 2} //rowspan即縱向跨越的單元格數(shù) ,{field: 'amount', title: '金額', width: 80, rowspan: 2} ,{align: 'center', title: '地址', colspan: 3} //colspan即橫跨的單元格數(shù),這種情況下不用設(shè)置field和width ], [ {field: 'province', title: '省', width: 80} ,{field: 'city', title: '市', width: 120} ,{field: 'county', title: '詳細(xì)', width: 300} ]] }); 它等價(jià)于: <table class="layui-table" lay-data="{基礎(chǔ)參數(shù)}"> <thead> <tr> <th lay-data="{field:'username', width:80}" rowspan="2">聯(lián)系人</th> <th lay-data="{field:'amount', width:120}" rowspan="2">金額</th> <th lay-data="{align:'center'}" colspan="3">地址</th> </tr> <tr> <th lay-data="{field:'province', width:80}">省</th> <th lay-data="{field:'city', width:120}">市</th> <th lay-data="{field:'county', width:300}">詳細(xì)</th> </tr> </thead> </table>聲明: 本文由我的SEOUC技術(shù)文章主頁發(fā)布于:2023-05-27 ,文章layui table模塊中如何使用前提參數(shù)?后端開發(fā)主要講述模塊,參數(shù),后端開發(fā)網(wǎng)站建設(shè)源碼以及服務(wù)器配置搭建相關(guān)技術(shù)文章。轉(zhuǎn)載請(qǐng)保留鏈接: http://www.bifwcx.com/article/web_11151.html
為你推薦與layui table模塊中如何使用前提參數(shù)?后端開發(fā)相關(guān)的文章
-
通王TWCMS 2.0.3網(wǎng)站模板程序下載
(126)人喜歡 2024-01-15 -
Windows官方原版在哪里下載
(175)人喜歡 2024-01-15 -
WordPress網(wǎng)站模板發(fā)帖標(biāo)題顏色設(shè)置
(131)人喜歡 2024-01-07 -
修改discuz論壇帖子標(biāo)題80字符的長(zhǎng)度限制
(249)人喜歡 2024-01-07 -
wordpress程序調(diào)用不帶超鏈接的Tag標(biāo)簽
(234)人喜歡 2024-01-05 -
網(wǎng)站在不同時(shí)期需調(diào)整內(nèi)容更新的方向
(112)人喜歡 2023-08-12