欧洲变态另类zozo,欧美xxxx做受欧美gaybdsm,欧洲熟妇色xxxx欧美老妇软件,免费人成视频xvideos入口 ,欧美.日韩.国产.中文字幕

歡迎光臨本站
我們一直在努力

微信小程序商城中側(cè)欄分類的效果實現(xiàn)

這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崙?zhàn)商城系列之側(cè)欄分類效果,具有一定的參考價值,感興趣的小伙伴們可以參考一下

在商場項目中,一般都會有分類頁面。
分類頁面可以給用戶快速找到相關(guān)的商品,下面以側(cè)欄分類為例,如下圖

布局分析:


左盒子>
右盒子>
主盒子>

左盒子使用標(biāo)準(zhǔn)流
右盒子使用絕對定位(top、right)

wxml:

<!--主盒子--> 
<view class="container"> 
 <!--左側(cè)欄--> 
 <view class="nav_left"> 
 <block wx:for="{{navLeftItems}}"> 
 <!--當(dāng)前項的id等于item項的id,那個就是當(dāng)前狀態(tài)--> 
 <!--用data-index記錄這個數(shù)據(jù)在數(shù)組的下標(biāo)位置,使用data-id設(shè)置每個item的id值,供打開2級頁面使用--> 
 <view class="nav_left_items {{curNav == item.id ? 'active' : ''}}" bindtap="switchRightTab" data-index="{{index}}" data-id="{{item.id}}">{{item.tree.desc}}</view> 
 </block> 
 </view> 
 <!--右側(cè)欄--> 
 <view class="nav_right"> 
 <!--如果有數(shù)據(jù),才遍歷項--> 
 <view wx:if="{{navRightItems[curIndex].tree.nodes[1].tree.nodes}}"> 
 <block wx:for="{{navRightItems[curIndex].tree.nodes[1].tree.nodes}}"> 
 <view class="nav_right_items"> 
  <navigator url="../list/index?brand={{item.tree.id}}&typeid={{navRightItems[curIndex].id}}"> 
  <!--用view包裹圖片組合,如果有圖片就用,無圖片提供就使用50x30的這個默認(rèn)圖片--> 
  <view>  
  <block wx:if="{{item.tree.logo}}"> 
  <image src="{{item.tree.logo}}"></image> 
  </block> 
  <block wx:else> 
  <image src="http://temp.im/50x30"></image> 
  </block> 
  </view> 
  <!--如果有文字,就用文字;無文字就用其他--> 
  <view wx:if="{{item.tree.desc}}"> 
  <text>{{item.tree.desc}}</text> 
  </view> 
  <view wx:else> 
  <text>{{item.tree.desc2}}</text> 
  </view> 
  </navigator> 
 </view> 
 </block> 
 </view> 
 <!--如果無數(shù)據(jù),則顯示數(shù)據(jù)--> 
 <view wx:else>暫無數(shù)據(jù)</view> 
 </view> 
</view>
登錄后復(fù)制

wxss:

page{ 
 background: #f5f5f5; 
} 
/*總體主盒子*/ 
.container { 
 position: relative; 
 width: 100%; 
 height: 100%; 
 background-color: #fff; 
 color: #939393; 
} 

/*左側(cè)欄主盒子*/ 
.nav_left{ 
 /*設(shè)置行內(nèi)塊級元素(沒使用定位)*/ 
 display: inline-block; 
 width: 25%; 
 height: 100%; 
 /*主盒子設(shè)置背景色為灰色*/ 
 background: #f5f5f5; 
 text-align: center; 
} 
/*左側(cè)欄list的item*/ 
.nav_left .nav_left_items{ 
 /*每個高30px*/ 
 height: 30px; 
 /*垂直居中*/ 
 line-height: 30px; 
 /*再設(shè)上下padding增加高度,總高42px*/ 
 padding: 6px 0; 
 /*只設(shè)下邊線*/ 
 border-bottom: 1px solid #dedede; 
 /*文字14px*/ 
 font-size: 14px; 
} 
/*左側(cè)欄list的item被選中時*/ 
.nav_left .nav_left_items.active{ 
 /*背景色變成白色*/ 
 background: #fff; 
} 

/*右側(cè)欄主盒子*/ 
.nav_right{ 
 /*右側(cè)盒子使用了絕對定位*/ 
 position: absolute; 
 top: 0; 
 right: 0; 
 flex: 1; 
 /*寬度75%,高度占滿,并使用百分比布局*/ 
 width: 75%; 
 height: 100%; 
 padding: 10px; 
 box-sizing: border-box; 
 background: #fff; 
} 
/*右側(cè)欄list的item*/ 
.nav_right .nav_right_items{ 
 /*浮動向左*/ 
 float: left; 
 /*每個item設(shè)置寬度是33.33%*/ 
 width: 33.33%; 
 height: 80px; 
 text-align: center; 
} 
.nav_right .nav_right_items image{ 
 /*被圖片設(shè)置寬高*/ 
 width: 50px; 
 height: 30px; 
} 
.nav_right .nav_right_items text{ 
 /*給text設(shè)成塊級元素*/ 
 display: block; 
 margin-top: 5px; 
 font-size: 10px; 
 /*設(shè)置文字溢出部分為...*/ 
 overflow: hidden; 
 white-space: nowrap; 
 text-overflow: ellipsis; 
}
登錄后復(fù)制

js:

Page({ 
 data: { 
 navLeftItems: [], 
 navRightItems: [], 
 curNav: 1, 
 curIndex: 0 
 }, 
 onLoad: function() { 
 // 加載的使用進(jìn)行網(wǎng)絡(luò)訪問,把需要的數(shù)據(jù)設(shè)置到data數(shù)據(jù)對象 
 var that = this  
 wx.request({ 
  url: 'http://huanqiuxiaozhen.com/wemall/goodstype/typebrandList', 
  method: 'GET', 
  data: {}, 
  header: { 
  'Accept': 'application/json' 
  }, 
  success: function(res) { 
  console.log(res) 
  that.setData({ 
   navLeftItems: res.data, 
   navRightItems: res.data 
  }) 
  } 
 }) 
 }, 

 //事件處理函數(shù) 
 switchRightTab: function(e) { 
 // 獲取item項的id,和數(shù)組的下標(biāo)值 
 let id = e.target.dataset.id, 
  index = parseInt(e.target.dataset.index); 
 // 把點擊到的某一項,設(shè)為當(dāng)前index 
 this.setData({ 
  curNav: id, 
  curIndex: index 
 }) 
 } 

})
登錄后復(fù)制

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,更多相關(guān)內(nèi)容請關(guān)注PHP中文網(wǎng)!

相關(guān)推薦:

以上就是微信小程序商城中側(cè)欄分類的效果實現(xiàn)的詳細(xì)內(nèi)容,更多請關(guān)注有卡有網(wǎng)。

版權(quán)聲明:本文采用知識共享 署名4.0國際許可協(xié)議 [BY-NC-SA] 進(jìn)行授權(quán)
文章名稱:《微信小程序商城中側(cè)欄分類的效果實現(xiàn)》
文章鏈接:http://www.ljxxtl.cn/kaquan-baike/xcx/154654.html
本站資源僅供個人學(xué)習(xí)交流,請于下載后24小時內(nèi)刪除,不允許用于商業(yè)用途,否則法律問題自行承擔(dān)。