91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

小程序實現折疊菜單效果的示例代碼

發布時間:2021-01-28 13:03:24 來源:億速云 閱讀:205 作者:小新 欄目:移動開發

小編給大家分享一下小程序實現折疊菜單效果的示例代碼,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!

通常,菜單都有一級菜單二級、三級菜單之分,我們知道前端js的dom操作可以很好的控制二級菜單的顯示與隱藏,當然今天我就不介紹web端的菜單折疊效果。我今天呢,是來學習學習小程序中該如何實現點擊一級菜單顯示/隱藏二級菜單,并且在點擊一個菜單顯示之外,要實現其他菜單隱藏。

實現效果如下:

小程序實現折疊菜單效果的示例代碼

代碼如下:

.wxml文件

<view class="cells">
    <view class="item"  wx:for="{{List}}" wx:for-index="idx" wx:for-item="item" wx:key="idx">
        <view bindtap="isOpen" class="cdn" data-index="{{item.id}}">
            <view>
                <image class="img" src="{{item.iamges}}" mode="aspectFill"/><text class="content">{{item.cont}}</text>
            </view>
            <view>
                <text class="discount">{{item.discount}}</text><image class="icon_img" src="{{item.hidden ? '/assets/icon_down2x.png' : '/assets/icon_up2x.png'}}" mode="aspectFill"/>
            </view>
        </view>
        <view hidden="{{item.hiddena}}"  class="hidden">
            <block wx:for="{{item.invalidActivty}}"  wx:for-index="index" wx:for-item="items" wx:key="index">
                <view class="buys">
                    <view class="v1 ">
                        <navigator><text class="new-price">{{items.price}}</text><text class="oldPrice">{{items.oldPrice}}</text></navigator>
                        <navigator><text class="buy">{{items.validType}}</text><text style="font-size: 24rpx;margin-left: 20rpx;color: #6C6C6C">{{items.validTime}}</text></navigator>
                    </view>
                    <view  class="shopping">
                        <text>購買</text>
                    </view>
                </view>
            </block>
        </view>
    </view>
</view>

.wxss文件如下:

page{
    background: #fff;
}
.swiper-img{
    width: 750rpx;
    height: 300rpx;
}
.cells .item .cdn{
    position: relative;
    box-sizing:border-box;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20rpx 30rpx;
    /*border-bottom: 1rpx solid #f0f0f0;*/
    background-color: #fff;
    font-size: 32rpx;
}
.cells .item .cdn::after{
    content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border-bottom:0 solid #f0f0f0;border-width:1px
}

.img{
    height: 44rpx;
    width: 44rpx;
    vertical-align: middle;
    display: inline-block;
    line-height: 82rpx;
}

.icon_img{
    height:12rpx;
    width:20rpx;
}



.content{
    margin-left: 15rpx;
    line-height: 82rpx;
    vertical-align: middle;
}

.discount{
    line-height: 82rpx;
    vertical-align: middle;
    color:orange;
    box-sizing: border-box;
    padding-right: 20rpx;
}


.video-item{
    display: flex;
    flex-direction: column;
}
.buys{
    width:750rpx;
    height: 141.6rpx;
    position: relative;
    box-sizing: border-box;
    padding: 20rpx 30rpx;
    display: flex;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    background-color:#FAFAFA;
}
.buys::after {
    content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;
    border-bottom:0 solid #DCDCDC;border-width:1px;
}
.v1{
    width: 35%;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
}

.new-price{
    font-size: 32rpx;
    color: #3B3B3B;
}
.oldPrice{
    text-decoration:line-through;
    font-size: 24rpx;
    color: #B0B0B0;
    margin-left: 20rpx;
}
.buy{
    font-size: 24rpx;
    color: #2DAF73;
    text-align: center;
    width: 80rpx;
    height: 40rpx;
    line-height: 40rpx;
    display: inline-block;
    position: relative;
    box-sizing: border-box;
}
.buy::after{
    content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #2DAF73;border-width:1px;border-radius:8rpx
}

.shopping{
    width: 128rpx;
    height: 56rpx;
    line-height: 56rpx;
    position: relative;
    box-sizing: border-box;
    font-size: 28rpx;
    color: #2DAF73;
    text-align: center;
}
.shopping::after{
    content:'';position:absolute;top:0;left:0;width:200%;height:200%;-webkit-transform:scale(.5);transform:scale(.5);-webkit-transform-origin:0 0;transform-origin:0 0;pointer-events:none;box-sizing:border-box;border:0 solid #2DAF73;border-width:1px;border-radius:16rpx
}

.js文件

data: {
    memberList:[
        {iamges:"/assets/logo_aiqiyi2x.png",
          cont:"愛奇藝影視會員",
          discount:"7.5折",
          hiddena:true,
          id:"0",
          invalidActivty:[
            {
              price:"2.98元",
              oldPrice:"3元",
              validType:"周卡",
              validTime:'7天有效'
            },
            {
                price:"18.98元",
                oldPrice:"25元",
                validType:"月卡",
                validTime:'30天有效'
            },
          ]
        },
        {iamges:"/assets/logo_tengxun2x.png",
            cont:"騰訊視頻會員",
            discount:"7折",
            hiddena:true,
            id:"1",
            invalidActivty:[
                {
                    price:"2.98元",
                    oldPrice:"3元",
                    validType:"周卡",
                    validTime:'7天有效'
                },
                {
                    price:"18.98元",
                    oldPrice:"25元",
                    validType:"月卡",
                    validTime:'30天有效'
                },
            ]
        },
        {iamges:"/assets/logo_youku2x.png",
            cont:"優酷視頻黃金會員",
            discount:"8折",
            hiddena:true,
            id:"2",
            invalidActivty:[
                {
                    price:"2.98元",
                    oldPrice:"3元",
                    validType:"周卡",
                    validTime:'7天有效'
                },
                {
                    price:"18.98元",
                    oldPrice:"25元",
                    validType:"月卡",
                    validTime:'30天有效'
                },
            ]
        },
        {iamges:"/assets/logo_sohu2x.png",
            cont:"搜狐視頻黃金會員",
            discount:"8折",
            hiddena:true,
            id:"3",
            invalidActivty:[
                {
                    price:"2.98元",
                    oldPrice:"3元",
                    validType:"周卡",
                    validTime:'7天有效'
                },
                {
                    price:"18.98元",
                    oldPrice:"25元",
                    validType:"月卡",
                    validTime:'30天有效'
                },
            ]
        },
    ]
  },
  isOpen:function(e){
      var that = this;
      var idx = e.currentTarget.dataset.index;
      console.log(idx);
      var memberList = that.data.MemberList;
      console.log(memberList);
      for (let i=0; i < memberList.length; i++){
          if (idx == i) {
              memberList[i].hidden=!memberList[i].hidden;
          } else {
             memberList[i].hidden=true;
          }
      }
      this.setData({MemberList:memberList});
      return true;
    },

看完了這篇文章,相信你對“小程序實現折疊菜單效果的示例代碼”有了一定的了解,如果想了解更多相關知識,歡迎關注億速云行業資訊頻道,感謝各位的閱讀!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

朝阳市| 大名县| 南雄市| 潜山县| 健康| 伊吾县| 孟州市| 安丘市| 屏南县| 汉中市| 唐河县| 伊吾县| 五大连池市| 大丰市| 阳城县| 兰坪| 云梦县| 濉溪县| 吉木乃县| 临夏市| 胶州市| 革吉县| 绥棱县| 淮滨县| 武山县| 兴化市| 郎溪县| 南靖县| 琼中| 钟祥市| 老河口市| 湘乡市| 招远市| 密云县| 昌江| 高清| 昭通市| 沛县| 平顶山市| 普洱| 边坝县|