温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

如何在微信小程序中制作表格

发布时间:2021-05-20 16:59:57 阅读:531 作者:Leah 栏目:web开发
开发者测试专用服务器限时活动,0元免费领,库存有限,领完即止! 点击查看>>

如何在微信小程序中制作表格?相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。

在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">{{item.code}}</view>
   <view class="td-2" selectable="true" scroll-y="true" >
   <text class="th-text"  selectable="true">{{item.text}}</text>
   </view>
   <!--view class="td">{{item.type}}</view-->
  </view>
  <view class="tr bg-g2" wx:else>
   <view class="td-1" selectable="true">{{item.code}}</view>
   <view class="td-2" selectable="true" scroll-y="true" >
   <text class="th-text"  selectable="true">{{item.text}}</text>
   </view>
  </view>
 </block>
</view>

在XXX.wxss中添加如下代码:

.table {
 border2px solid darkgray;
 width100%;
 margin-top1rem;
 margin-right1rem;
 margin-left1rem;
 
 
}
.tr {
 display: flex;
 width100%;
 justify-content: center;
 height3rem;
 align-items: center;
}
.td {
  width:20%;
  justify-content: center;
  display: flex;
  text-align: center;
  border-right2px solid #ddd;
  height100%;
}
.td-1 {
  width:19%;
  justify-content: center;
  display: flex;
  text-align: center;
  border-right2px solid #ddd;
  height100%;
}
.td-2 {
  width:80%;
  justify-content: center;
  border-right2px solid #ddd;
  text-align: left;
  height100%;
  max-width100%;
  padding40rpx 0;
}
.bg-w{
 background#afb4db;
 
}
.bg-g{
 background#E6F3F9;
}
.bg-g2{
 background#fff;
}
.th {
 width19%;
 justify-content: center;
 color#fff;
 display: flex;
 height3rem;
 align-items: center;
 border-right2px solid #ddd;
}
.th-2 {
 width80%;
 justify-content: center;
 color#fff;
 display: flex;
 height3rem;
 align-items: center;
 max-height3rem;
 max-width80%;
}.th-text {
 width80%;
 justify-content: center;
 color#000;
 display: block;
 height3rem;
 align-items: center;
 max-height3rem;
 max-width80%;
}

在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'', //用户输入的查询语句
 })

看完上述内容,你们掌握如何在微信小程序中制作表格的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!

亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI

开发者交流群×