js 获取table当前行值第一列_微信小程序实现多复杂表格table的colspan,rowspan效果等...

效果:

24eaa434910a340c6a118b7ad1cc8d16.png

可用选择月份,实现数据查询(必须后台数据交互),这里只是介绍实现的样式

7f327a21b11eae5b972de248f8ef29aa.png
7f0c8dc0667648a00485fe666d83af6f.png

index.html

{{currentDate}}{{username + " " + currentDate + " 月工资表"}}单位:元本月暂无工资数据{{item.name}}{{item.value}}{{item2.name}}{{item2.value}}{{item3.name}}{{item3.value}}

index.wxss

.container { width: 100%; display: flex; flex-direction: column; box-sizing: border-box; background: white;}.picker { width: 100%;}.date-text { font-size: 32rpx; padding: 20rpx 10rpx; text-align: center;}.title-wrapper { display: flex; width: 100%; justify-content: center; align-items: center; padding: 20rpx; box-sizing: border-box;}.title { flex: 1; font-size: 34rpx; text-align: center; font-weight: 700; color: #09bb07;}.yuan { font-size: 24rpx; color: #09bb07;}.table-wrapper { width: 100%; display: flex; flex-direction: column; border-top: 1rpx solid #DCDFE6;}.row1 { width: 100%; display: flex; flex-direction: row; align-items: center; font-size: 32rpx; box-sizing: border-box; border-bottom: 1rpx solid #DCDFE6; }.text { flex: 1; padding: 10rpx; line-height: 60rpx; height: 60rpx;}.column2-wrapper { display: flex; flex-direction: column; flex: 3; justify-content: center; border-left: 1rpx solid #DCDFE6;}.column2 { display: flex; flex: 1; align-items: center; border-bottom: 1rpx solid #DCDFE6;}.column2:last-child{ border-bottom: none;}.column3-wrapper { display: flex; flex-direction: column; flex: 2; justify-content: center; border-left: 1rpx solid #DCDFE6;}.column3 { display: flex; flex: 1; align-items: center; border-bottom: 1rpx solid #DCDFE6;}.column3:last-child{ border-bottom: none;}.column-value{ display: flex; align-self: flex-end; margin-right: 10rpx; padding: 10rpx; line-height: 60rpx; height: 60rpx;}.column4-wrapper{ display: flex; flex-direction: column; flex: 1; justify-content: center; border-left: 1rpx solid #DCDFE6;}.picker-content{ display: flex; width: 100%; justify-content: center; align-items: center; border-bottom: 1rpx solid rgba(7, 17, 27, 0.1);}.date-icon{ width: 80rpx; height: 80rpx;}.nodata{ width: 100%; text-align: center; font-size: 32rpx; color: #666; padding: 20rpx;}

index.js

import MockData from './mockdata.js'import { formatTime} from '../../utils/util.js'Page({ data: { currentDate: '', username: 'XXX', list: '' },  onLoad: function () { wx.setNavigationBarTitle({ title: '工资查询', }) //设置当前年月 this.setCurrentDate() this._getSalary() }, setCurrentDate(){ //获取当前年月 let date = new Date() let fmtDate = formatTime(date).substring(0, 7) this.setData({ currentDate: fmtDate, }) console.log(fmtDate) }, //日期变化回调 dateChange(res) { console.log(res) let value = res.detail.value this.setData({ currentDate: value }) //请求数据 this._getSalary() }, //模拟请求数据 _getSalary(){ this.setData({ list: MockData.data }) } })

mockdata.js(index.js里调用的模拟数据)

885ba084c4a49db57414d5df13738a58.png
// 模拟的数据export default { status: 200, code: "ok
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
实现复杂表格colspanrowspan效果等,可以结合使用 WXML 和 CSS 来完成。 对于colspanrowspan效果,可以使用 <view> 标签来实现。具体实现方式如下: 1. 对于colspan效果,可以使用 <view> 标签的 width 属性来控制单元格的宽度,然后使用 CSS 的 grid 布局或者 flex 布局来控制单元格的位置。 2. 对于rowspan效果,可以使用 <view> 标签的 height 属性来控制单元格的高度,然后使用 CSS 的 grid 布局或者 flex 布局来控制单元格的位置。 例如,一个包含colspanrowspan效果表格可以这样实现: ```html <view class="table"> <view class="row"> <view class="cell" rowspan="2">1</view> <view class="cell">2</view> <view class="cell" colspan="2">3</view> </view> <view class="row"> <view class="cell">4</view> <view class="cell">5</view> <view class="cell">6</view> </view> <view class="row"> <view class="cell">7</view> <view class="cell" rowspan="2">8</view> <view class="cell">9</view> <view class="cell">10</view> </view> <view class="row"> <view class="cell">11</view> <view class="cell">12</view> <view class="cell">13</view> </view> </view> ``` 然后使用 CSS 来设置单元格的样式和布局: ```css .table { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr; grid-template-rows: 1fr 1fr 1fr; } .row { display: flex; flex-direction: row; } .cell { display: flex; justify-content: center; align-items: center; border: 1px solid #ccc; } .cell[colspan="2"] { grid-column-end: span 2; } .cell[rowspan="2"] { grid-row-end: span 2; } ``` 这样就可以实现一个带有colspanrowspan效果表格了。当然,具体实现方式还需要根据实际需求进调整。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值