如何在微信小程序中制作表格?相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(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" 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" 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)容,你們掌握如何在微信小程序中制作表格的方法了嗎?如果還想學到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
文章題目:如何在微信小程序中制作表格-創(chuàng)新互聯(lián)
URL網(wǎng)址:http://www.chinadenli.net/article4/dioeie.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站建設(shè)、域名注冊、網(wǎng)站收錄、小程序開發(fā)、軟件開發(fā)、動態(tài)網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容