微信小程序制作表格代码「建议收藏」

微信小程序制作表格代码「建议收藏」微信小程序中没有专门的表格制作工具,不过使用列表渲染可以实现,下面是我做的表格图片:方法如下:在XXX.wxml中填写下面的代码参数内容{{item.code}}{{item.text}}{{item.type}}

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

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

下面是我做的表格图片:

微信小程序制作表格代码「建议收藏」

方法如下:

  1. 在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"  style="overflow-y:auto;overflow-x:scroll" 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"  style="overflow-y:auto;overflow-x:scroll" selectable="true">{
        
        {item.text}}</text>
         </view>
        </view>
      </block>
    </view>

  2. 在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%;}

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

小程序体验:扫下面的二维码
 微信小程序制作表格代码「建议收藏」



完整代码下载:


技术交流群:
微信小程序制作表格代码「建议收藏」

      

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/157840.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号