国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

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

2019-11-19 12:08:40
字體:
來源:轉載
供稿:網友

本文實例為大家分享了微信小程序制作表格的具體代碼。

微信小程序中沒有專門的表格制作工具,不過使用列表渲染可以實現,

下面是我做的表格圖片:

方法如下:

在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>

在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: '', //用戶輸入的查詢語句 })

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 玛纳斯县| 绥宁县| 南岸区| 建水县| 五常市| 清新县| 新田县| 武宁县| 兰坪| 苍溪县| 历史| 宜良县| 怀安县| 合山市| 忻城县| 睢宁县| 涟水县| 天气| 英德市| 曲沃县| 惠州市| 股票| 文水县| 北京市| 墨江| 定日县| 三原县| 红河县| 津市市| 荔浦县| 长兴县| 扬州市| 岱山县| 长顺县| 三亚市| 本溪市| 望江县| 连山| 黄陵县| 丰城市| 东海县|