麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 課堂 > 小程序 > 正文

微信小程序實現左右列表聯動

2020-03-21 16:02:06
字體:
來源:轉載
供稿:網友

本文實例為大家分享了微信小程序實現左右列表聯動的具體代碼,供大家參考,具體內容如下

效果圖:

微信小程序,左右列表,聯動

微信小程序,左右列表,聯動

直接上代碼:

wxml界面:

<view class='header'> <text class='headerClass'>分類</text><text class='headerPin'>/品牌</text> <view class="search"> <image src='/images/搜索.png'></image><text>搜索商品</text> </view> </view> <view class='main'> <view class='left'> <scroll-view scroll-y="true" style="height: 1100rpx" scroll-into-view="true" scroll-with-animation="true"> <block wx:for="{{leftText}}" wx:for-list="item"> <view class="{{classfiySelect == item.id?'active':''}}" data-id='{{item.id}}' bindtap='left_list'> <text>{{item.text1}}</text> </view></block></scroll-view></view><view class='right'> <scroll-view scroll-y="true" style="height: 1100rpx" bindscroll="scroll" scroll-top="{{scrollTop}}" scroll-into-view="{{'inToview'+rigId}}" scroll-with-animation="true"><block wx:for="{{rightData}}" wx:for-list="item"><view class='itemTitle' id="{{'inToview'+item.id}}">{{item.title}}</view><view bindtap='particulars' class='listItem' data-id='{{item.id}}'> <block wx:for="{{item.frist}}"><view class='listItem2' data-text="{{}}"> <view class='img'> <image src='{{item.url}}'></image> </view> <view class='listText'> <text>{{item.text}}</text><text class='money'>¥{{item.money}}</text><view><text>已售{{item.sum}}</text><button size='mini' bindtap='particulars'>立即搶購</button></view> </view> </view> </block></view> </block> </scroll-view></view></view>

js界面:

// pages/class/class.jsPage({  /** * 頁面的初始數據 */ data: { classfiySelect: "", leftText: [{ id: "01", text1: "美妝專區", }, { id: "02", text1: "面部清潔", }, { id: "03", text1: "洗護專區", }, { id: "04", text1: "面膜", }, { id: "05", text1: "口紅", }, { id: "06", text1: "美妝專區", }, { id: "07", text1: "面部清潔", }, { id: "08", text1: "洗護專區", }, { id: "09", text1: "面膜", }, { id: "010", text1: "口紅", }, { id: "011", text1: "美妝專區", }, { id: "012", text1: "面部清潔", }, { id: "013", text1: "洗護專區", }, { id: "014", text1: "面膜", }, { id: "015", text1: "口紅", }, { text1: "美妝專區", }, { text1: "面部清潔", }, { text1: "洗護專區", }, { text1: "面膜", }, { text1: "口紅", },  ], rightData: [{ id: "01", title: "美妝專區", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  id:1,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  id: 2,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, { id: "02", title: "面部清潔", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, { id: "03", title: "洗護專區", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, { id: "04", title: "面膜", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, { id: "05", title: "口紅", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, { id: "06", title: "美妝專區", frist: [{  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  },  {  url: "/images/85309.jpg",  text: "卡姿蘭補水套裝",  money: 200,  sum: 20,  }, ], }, ], },  /** * 生命周期函數--監聽頁面加載 */ onLoad: function(options) { this.setData({ classfiySelect: this.data.leftText[0].id }) },  /** * 生命周期函數--監聽頁面初次渲染完成 */ onReady: function() {  },  /** * 生命周期函數--監聽頁面顯示 */ onShow: function() {  },  /** * 生命周期函數--監聽頁面隱藏 */ onHide: function() {  },  /** * 生命周期函數--監聽頁面卸載 */ onUnload: function() {  },  /** * 頁面相關事件處理函數--監聽用戶下拉動作 */ onPullDownRefresh: function() {  },  /** * 頁面上拉觸底事件的處理函數 */ onReachBottom: function() {  },  /** * 用戶點擊右上角分享 */ onShareAppMessage: function() {  }, //滾動觸發 scroll: function(e) { var scrollTop = e.detail.scrollTop, h = 0, classfiySelect; var that = this; that.data.leftText.forEach(function(clssfiy, i) { var _h =26 + that.length(clssfiy['id'])*102; if (scrollTop >= h){ classfiySelect = clssfiy['id']; } h +=_h; console.log(h); }) that.setData({ classfiySelect: classfiySelect, }) }, //求每一欄高度 length: function(e) { var that = this; var rightData = that.data.rightData; for (var i = 0; i < rightData.length; i++) { if(rightData[i]['id']==e){ return rightData[i]['frist'].length;  } } }, //點擊左邊事件 left_list: function(e) { var that = this; var l_id = e.currentTarget.dataset.id; that.setData({ rigId: l_id, }) }, //跳轉詳情界面 particulars:function(e){  }})

wxss界面:

.header{ display: flex; background-color: rgba(219, 219, 221, 0.884); align-items: center; height: 60rpx;}.active{ color: red;}.header .headerClass{ color: red; margin-left: 20rpx;}.header .headerClass,.header .headerPin{ font-size: 28rpx;}.search{ display: flex; height: 46rpx; border-radius: 20rpx; margin-left: 30rpx; background-color:white; width: 70%;}.search text{ color: gainsboro; font-family: monospace; font-size: 30rpx; line-height: 46rpx; }.search image{ padding-left:50rpx;  width: 46rpx; height: 46rpx;}.main{ display: flex;}.left{ width: 25%}.left view{ padding-top: 30rpx; text-align: center;}.right{ width: 75%; } .listItem2{ display: flex;}.listItem .img{ width: 200rpx; height: 200rpx; text-align: center; padding-top: 10rpx;}.listItem .img image{ width: 80%; height: 80%}.itemTitle{ font-size: 32rpx; padding-left: 20rpx; padding-top: 10rpx; color:gray;}.listItem .listText{ display: flex; flex-direction: column; margin-top: 6rpx;}.listItem .listText view{ display: flex; align-items: flex-end;}.listItem .listText text{ font-size: 34rpx; margin-top: 10rpx;}.listItem .listText .money{ color: red;}.listItem .listText view text{ font-size: 28rpx; color :silver; margin-right: 60rpx;}.listItem .listText view button{ background-color: red; color: white; padding-right: 8px; padding-left: 8px; padding-top: 0px;}::-webkit-scrollbar{width: 6px;height: 6px;background-color: #ffffff;} ::-webkit-scrollbar-track{ height: 20rpx; color: black;}

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


發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 91久久久久 | 中文字幕亚洲欧美 | 国产免费一区二区三区视频 | 日本中文字幕高清 | 九一免费版在线观看 | 成人在线免费观看视频 | 一分钟免费观看完整版电影 | 国产精品久久久久久久久久久久午夜 | 91www成人久久 | 天堂福利电影 | 久久精品在线免费观看 | 国产精品91久久久 | 中文字幕涩涩久久乱小说 | 毛片福利 | 色视频欧美| 欧美国产精品久久 | av在线播放电影 | 成人午夜视频在线观看免费 | 欧美综合在线观看 | 一级毛片电影网 | 国产精品久久久久久久午夜片 | 欧美精品日日鲁夜夜添 | 国产一区二区午夜 | 欧美日韩中文字幕在线视频 | 久久久www视频| 免费黄网站在线播放 | 国产又粗又爽又深的免费视频 | 蜜桃网在线观看 | 桥本有菜免费av一区二区三区 | 美女黄污视频 | 性盈盈盈影院 | 亚洲片在线观看 | 性欧美大战久久久久久久免费观看 | 亚洲午夜1000理论片aa | 嗯啊羞羞视频 | 亚洲天堂在线电影 | 国产精品av久久久久久久久久 | 香蕉久久久精品 | 色七七久久影院 | 粉嫩粉嫩一区二区三区在线播放 | 少妇一级淫片免费看 |