小程序 微信统计表格_微信小程序制作表格的方法

本文实例为大家分享了微信小程序制作表格的具体代码。

微信小程序中没有专门的表格制作工具,不过使用列表渲染可以实现,

下面是我做的表格图片:

方法如下:

在XXX.wxml中填写下面的代码

参数

内容

{{item.code}}

{{item.text}}

{{item.code}}

{{item.text}}

在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定义下面的数据

var idinfolist = [

{ "code": "结果", "text": '' },

{ "code": "省", "text": '' },

{ "code": "市", "text": '' },

{ "code": "县", "text": ''},

{ "code": "性别", "text": ''},

{ "code": "出生年月", "text": ''},

{ "code": "地址", "text": ''}

]

Page({

data: {

listData: idinfolist,

inputValue: '', //用于显示输入语句

searchinput: '', //用户输入的查询语句

})

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
制作一个表格,需要用到小程序的<scroll-view>、<view>、<text>等组件。 以下是一个简单的例子: 1. 在wxml中编写表格的结构: ``` <scroll-view class="table-container"> <view class="table-header"> <text class="table-cell">姓名</text> <text class="table-cell">年龄</text> <text class="table-cell">性别</text> </view> <view class="table-row"> <text class="table-cell">小明</text> <text class="table-cell">18</text> <text class="table-cell">男</text> </view> <view class="table-row"> <text class="table-cell">小红</text> <text class="table-cell">20</text> <text class="table-cell">女</text> </view> </scroll-view> ``` 2. 在wxss中编写表格的样式: ``` .table-container { height: 300rpx; width: 100%; border: 1rpx solid #ccc; overflow: scroll; } .table-header { display: flex; flex-direction: row; justify-content: space-between; background-color: #f5f5f5; border-bottom: 1rpx solid #ccc; } .table-row { display: flex; flex-direction: row; justify-content: space-between; border-bottom: 1rpx solid #ccc; } .table-cell { width: 33.3%; text-align: center; } ``` 3. 在js中添加数据: ``` Page({ data: { tableData: [ {name: "小明", age: 18, gender: "男"}, {name: "小红", age: 20, gender: "女"} ] } }) ``` 4. 在wxml中使用数据渲染表格: ``` <scroll-view class="table-container"> <view class="table-header"> <text class="table-cell">姓名</text> <text class="table-cell">年龄</text> <text class="table-cell">性别</text> </view> <view wx:for="{{tableData}}" wx:key="index" class="table-row"> <text class="table-cell">{{item.name}}</text> <text class="table-cell">{{item.age}}</text> <text class="table-cell">{{item.gender}}</text> </view> </scroll-view> ``` 这样就可以制作一个简单表格了。你可以根据自己的需求,对表格进行进一步的美化和优化。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值