微信小程序制作表格的方法
本文實(shí)例為大家分享了微信小程序制作表格的具體代碼。
微信小程序中沒有專門的表格制作工具,不過使用列表渲染可以實(shí)現(xiàn),
下面是我做的表格圖片:
方法如下:
在XXX.wxml中填寫下面的代碼
<view class="table"> <view class="tr bg-w"> <view class="th">參數(shù)</view> <view class="th-2">內(nèi)容</view> </view> <block wx:for="{{listData}}" wx:key="{[code]}"> <view class="tr bg-g" wx:if="{{index % 2 == 0}}"> <view class="td-1" selectable="true">{{item.code}}</view> <view class="td-2" selectable="true" scroll-y="true" > <text class="th-text" style="overflow-y:auto;overflow-x:scroll" selectable="true">{{item.text}}</text> </view> <!--view class="td">{{item.type}}</view--> </view> <view class="tr bg-g2" wx:else> <view class="td-1" selectable="true">{{item.code}}</view> <view class="td-2" selectable="true" scroll-y="true" > <text class="th-text" style="overflow-y:auto;overflow-x:scroll" selectable="true">{{item.text}}</text> </view> </view> </block> </view>
在XXX.wxss中添加如下代碼:
.table { border: 2px solid darkgray; width: 100%; margin-top: 1rem; margin-right: 1rem; margin-left: 1rem; } .tr { display: flex; width: 100%; justify-content: center; height: 3rem; align-items: center; } .td { width:20%; justify-content: center; display: flex; text-align: center; border-right: 2px solid #ddd; height: 100%; } .td-1 { width:19%; justify-content: center; display: flex; text-align: center; border-right: 2px solid #ddd; height: 100%; } .td-2 { width:80%; justify-content: center; border-right: 2px solid #ddd; text-align: left; height: 100%; max-width: 100%; padding: 40rpx 0; } .bg-w{ background: #afb4db; } .bg-g{ background: #E6F3F9; } .bg-g2{ background: #fff; } .th { width: 19%; justify-content: center; color: #fff; display: flex; height: 3rem; align-items: center; border-right: 2px solid #ddd; } .th-2 { width: 80%; justify-content: center; color: #fff; display: flex; height: 3rem; align-items: center; max-height: 3rem; max-width: 80%; }.th-text { width: 80%; justify-content: center; color: #000; display: block; height: 3rem; align-items: center; max-height: 3rem; max-width: 80%; }
在XXX.js頁面的pages定義下面的數(shù)據(jù)
var idinfolist = [ { "code": "結(jié)果", "text": '' }, { "code": "省", "text": '' }, { "code": "市", "text": '' }, { "code": "縣", "text": ''}, { "code": "性別", "text": ''}, { "code": "出生年月", "text": ''}, { "code": "地址", "text": ''} ] Page({ data: { listData: idinfolist, inputValue: '', //用于顯示輸入語句 searchinput: '', //用戶輸入的查詢語句 })
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
在JavaScript中使用Promise.allSettled()的方法
Promise.allSettled()是一個游戲規(guī)則改變者,讓您等待所有承諾得到解決(解決或拒絕),然后根據(jù)結(jié)果采取行動,這篇文章主要介紹了如何在JavaScript中使用Promise.allSettled(),需要的朋友可以參考下2023-07-07JavaScript正則表達(dá)式驗(yàn)證登錄實(shí)例
這篇文章主要為大家詳細(xì)介紹了JavaScript正則表達(dá)式驗(yàn)證登錄實(shí)例,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03js學(xué)使用setTimeout實(shí)現(xiàn)輪循動畫
這篇文章主要為大家詳細(xì)介紹了js使用setTimeout實(shí)現(xiàn)輪循動畫,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-07-07JS使用window.requestAnimationFrame()對列表切片進(jìn)行渲染
這篇文章主要為大家介紹了JS使用requestAnimationFrame對列表切片進(jìn)行渲染,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-05-05利用momentJs做一個倒計(jì)時(shí)組件(實(shí)例代碼)
這篇文章主要介紹了利用momentJs做一個倒計(jì)時(shí)組件,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-12-12Bootstrap基本組件學(xué)習(xí)筆記之導(dǎo)航(10)
這篇文章主要為大家詳細(xì)介紹了Bootstrap基本組件學(xué)習(xí)筆記之導(dǎo)航,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2016-12-12原生js實(shí)現(xiàn)trigger方法示例代碼
這篇文章主要給大家介紹了關(guān)于利用原生js實(shí)現(xiàn)trigger方法的相關(guān)資料,文中通過示例代碼介紹的非常詳細(xì),對大家學(xué)習(xí)或者使用js具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面來一起學(xué)習(xí)學(xué)習(xí)吧2019-05-05js確認(rèn)刪除對話框適用于a標(biāo)簽及submit
這篇文章主要介紹的是一個js確認(rèn)刪除對話框適用于a標(biāo)簽及submit,非常好用,需要的朋友不要錯過2014-07-07