微信小程序table表格-隔行换色

在这里插入图片描述
wxml

  <view class="table">
<view class="tableTr">
  <view class="Tr">厂商品牌</view>
  <view class="Tr">销量</view>
  <view class="Tr">同比增长</view>
  <view class="Tr">环比增长</view>
</view>
<block wx:for="{{list}}">
  <view class="tableTd" style="background:#F3F7FA;" wx:if="{{index%2===0}}">
    <view class="Td">{{item.name}}</view>
    <view class="Td">{{item.size}}</view>
    <view class="Td">{{item.height}}</view>
    <view class="Td">{{item.width}}</view>
  </view>
  <view class="tableTd" style="background: #FFFFFF;" wx:else>
    <view class="Td">{{item.name}}</view>
    <view class="Td">{{item.size}}</view>
    <view class="Td">{{item.height}}</view>
    <view class="Td">{{item.width}}</view>
  </view>
</block>
<!-- 上拉加载更多 -->
<view class="aa CommonWight">上拉加载更多</view>
就是使用block 循环,wx:if 做判断 奇数偶数

wxss

	.tabls {
background: #ffffff;
margin-top: 20rpx;
border-radius: 12rpx;
}

.tabls_top {
height: 94rpx;
display: flex;
justify-content: space-between;
align-items: center;
box-sizing: border-box;
padding: 0 20rpx 0 20rpx;
}

.tables_title {
font-size: 32rpx;
font-family: PingFang-SC-Bold, PingFang-SC;
font-weight: bold;
color: #333333;
}

.btn {
font-size: 24rpx !important;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #0080FF;
height: 40rpx !important;
background: #ffffff;
}

.table {
border: 0px solid darkgray;
height: 540rpx;
}

.tableTr {
display: flex;
justify-content: space-around;
align-items: center;
width: 99%;
height: 50rpx;
background: #FFFFFF;
box-shadow: 0px 0px 12px 0px rgba(0, 128, 255, 0.2);
border-radius: 12rpx;
border: 1px solid #0080FF;
}

.Tr {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #0080FF;
flex: 0.25;
text-align: center;
}

.tableTd {
height: 48rpx;
display: flex;
width: 99%;
border-radius: 12rpx;
align-items: center;
}

.Td {
font-size: 20rpx;
font-family: PingFangSC-Regular, PingFang SC;
font-weight: 400;
color: #666666;
flex: 0.25;
text-align: center;
}

wxjs

    list: [
        { name: "阿斯顿0", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿1", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿2", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿3", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿4", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿5", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿6", size: 666, height: "0.1", width: "0.2" },
        { name: "阿斯顿7", size: 666, height: "0.1", width: "0.2" },
    ]
  • 2
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值