⼩程序制作表格代码⼩程序中没有专门的表格制作⼯具,不过使⽤列表渲染可以实现,
下⾯是我做的表格图⽚:
⽅法如下:
1. 在XXX.wxml中填写下⾯的代码
<view class="table">
<view class="tr bg-w">
<view class="th">参数</view>
<view class="th-2">内容</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">{{de}}</view>
<view class="td-2" selectable="true" scroll-y="true" >
<text class="th-text" selectable="true">{{}}</text> </view>
<!--view class="td">{{pe}}</view-->
</view>
<view class="tr bg-g2" wx:else>
<view class="td-1" selectable="true">{{de}}</view>
<view class="td-2" selectable="true" scroll-y="true" >
<text class="th-text" selectable="true">{{}}</text> </view>
</view>
</block>
</view>
2. 在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;
color: #000;
display: block;
height: 3rem;
align-items: center;
max-height: 3rem;
max-width: 80%;
}
3. 在XXX.js页⾯的pages定义下⾯的数据
var idinfolist = [
{ "code": "结果", "text": '' },
{ "code": "省", "text": '' },
{ "code": "市", "text": '' },
{ "code": "县", "text": ''},
{ "code": "性别", "text": ''},
{ "code": "出⽣年⽉", "text": ''},
{ "code": "地址", "text": ''}
]
Page({
data: {
listData: idinfolist,
inputValue: '', //⽤于显⽰输⼊语句
searchinput: '', //⽤户输⼊的查询语句
})
⼩程序体验:扫下⾯的⼆维码
完整代码下载:
技术交流:
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论