欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序?qū)崿F(xiàn)側(cè)邊欄分類

 更新時(shí)間:2019年10月21日 11:58:35   作者:csdn_小東  
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)側(cè)邊欄分類,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了微信小程序側(cè)邊欄分類展示的具體代碼,供大家參考,具體內(nèi)容如下

效果圖

實(shí)現(xiàn)思路

把屏幕當(dāng)成一個(gè)固定的盒子,然后把盒子分成兩邊,并讓盒子的每一邊都能夠滾動。

源碼

index.wxml

<!--主盒子-->
<view class="container">
 <!--左側(cè)欄-->
 <view class="nav_left">
  <block wx:for="{{title}}" wx:for-item="item" wx:key="{{index}}">
   <!-- {{curNav == item.id ? 'active' : ''}} -->
   <!-- 三目運(yùn)算符是用來給當(dāng)前選中的目錄修改樣式用的 -->
   <!-- switchRightTab 函數(shù)是用來實(shí)現(xiàn)數(shù)據(jù)的渲染 -->
   <!-- 當(dāng)用戶點(diǎn)擊道不同的側(cè)邊欄目錄時(shí)候,根據(jù) data-id 去從數(shù)據(jù)庫獲取新的數(shù)據(jù),渲染到左側(cè),并且修改 curNav 的值,使新樣式添加到點(diǎn)擊的目錄上,具體 js 自己實(shí)現(xiàn) -->
   <view class="nav_left_items {{curNav == item.id ? 'active' : ''}}" bindtap="switchRightTab" data-id="{{item.id}}">{{item.name}}</view>
  </block>
 </view>

 <!--右側(cè)欄-->
 <view class="nav_right">
  <view class="nav_right_items">
   <block wx:for="{{content}}" wx:for-item="item" wx:key="{{index}}">
    <view>
     <text>{{item.name}}</text>
    </view>
   </block>
  </view>
 </view>
</view>

index.wxss

page {
 background: #f5f5f5;
}

/*總體主盒子*/

.container {
 display: flex;
 direction: row;
}

/*左側(cè)欄主盒子*/

.nav_left {
 /*設(shè)置行內(nèi)塊級元素(沒使用定位)*/
 position: absolute;
 display: inline-block;
 width: 35%;
 height: 100%;
 /*主盒子設(shè)置背景色為灰色*/
 background: #f5f5f5;
 text-align: center;
 overflow: scroll;
}

/*左側(cè)欄list的item*/

.nav_left .nav_left_items {
 /*每個(gè)高30px*/
 height: 30px;
 /*垂直居中*/
 line-height: 30px;
 /*再設(shè)上下padding增加高度,總高42px*/
 padding: 6px 0;
 /*只設(shè)下邊線*/
 border-bottom: 1px solid #dedede;
 /*文字14px*/
 font-size: 20px;
}

/*左側(cè)欄list的item被選中時(shí)*/

.nav_left .nav_left_items.active {
 /*背景色變成白色*/
 background: #fff;
 color: red;
}

/*右側(cè)欄主盒子*/

.nav_right {
 /*右側(cè)盒子使用了絕對定位*/
 position: absolute;
 top: 0;
 right: 0;
 flex: 1;
 /*寬度75%,高度占滿,并使用百分比布局*/
 width: 65%;
 height: 100%;
 padding: 10px;
 box-sizing: border-box;
 background: #fff;
 overflow: scroll;
}

.nav_right .nav_right_items {
}

.nav_right .nav_right_items text {
 /*給text設(shè)成塊級元素*/
 display: block;
 margin-bottom: 25px;
 font-size: 20px;
 /*設(shè)置文字居中*/
 text-align: left;
 /*設(shè)置文字溢出部分為...*/
 overflow: hidden;
 white-space: nowrap;
 text-overflow: ellipsis;
}

index.js

Page({
 data: {
  curNav: 0,
  title:[
   {
    "id":0,
    "name":"技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },

   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   },
   {
    "id": 1,
    "name": "技術(shù)"
   }
  ],
  content:[
   {
    id:2,
    "name":"軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   },
   {
    id: 2,
    "name": "軟件工程師"
   }
  ]
 }
})

更多教程點(diǎn)擊《Vue.js前端組件學(xué)習(xí)教程》,歡迎大家學(xué)習(xí)閱讀。

關(guān)于vue.js組件的教程,請大家點(diǎn)擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論