问题
uni-th 在这边是不固定的列数的,即dataList会变
在uni-th 设置固定列宽width='200',或者在uni-td 设置不生效,宽度不对
解决方法文章来源:https://www.toymoban.com/news/detail-736943.html
在uni-td里面多包一层view,通过设置view的宽度来撑开uni-td文章来源地址https://www.toymoban.com/news/detail-736943.html
<uni-td v-for="(item,index) in dataList">
<view style="width: 150px;">
<uni-easyinput type="number" v-model="item.pull" @input="numberFixedDigit($event,index)"></uni-easyinput>
</view>
</uni-td>
看代码
<uni-table border stripe emptyText="暂无更多数据">
<uni-tr>
<uni-th align="center">表头1</uni-th>
<uni-th width="200" v-for="item in dataList">
<text class="th-Font-big">{{item.eur}}</text>
</uni-th>
</uni-tr>
<uni-tr>
<uni-td align="center">表头2</uni-td>
<uni-td v-for="item in dataList">{{item.total}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center">表头3</uni-td>
<uni-td v-for="item in dataList">
<text class="text-red">{{item.total-item.all}}</text></uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center">表头4</uni-td>
<uni-td v-for="item in dataList">{{item.before}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center">表头5</uni-td>
<uni-td v-for="item in dataList">{{item.today}}</uni-td>
</uni-tr>
<uni-tr>
<uni-td align="center">
<picker mode="date" :value="dates" @change="bindDateChange">
<view class="uni-input" style="width: 200px;">日期:{{dates}}</view>
</picker>
</uni-td>
<uni-td v-for="(item,index) in dataList">
<view style="width: 150px;">
<uni-easyinput type="number" v-model="item.pull" @input="numberFixedDigit($event,index)"></uni-easyinput>
</view>
</uni-td>
</uni-tr>
</uni-table>
到了这里,关于uni-table动态列设置列宽不生效的解决方法的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!