亚洲乱码中文字幕综合,中国熟女仑乱hd,亚洲精品乱拍国产一区二区三区,一本大道卡一卡二卡三乱码全集资源,又粗又黄又硬又爽的免费视频

微信小程序實現(xiàn)滑動側邊欄

 更新時間:2022年07月17日 16:05:01   作者:癡夢_MM  
這篇文章主要為大家詳細介紹了微信小程序實現(xiàn)滑動側邊欄,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

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

效果圖:

手指向右滑動可以顯示側邊欄,向左滑動隱藏側邊欄

代碼附上:.wxml

<view class="title">
? ? ? <image ?class='headPortrait' src='../../images/1.jpg'></image> ?
? ? ? ? ? ? ?<text>趙國偉</text> ?
? ? ? ? ? ? </view>
? ? ? ? ? ? <view class="nav_left_items {{click == 1 ? 'active' : ''}}"?
? ? ? ? ? bindtap="switchRightTab" ?data-id="1" >
? ? ? ? ? ? ? ? <image ?class='icon' src='../../images/get.png'></image>
? ? ? ? ? ? ? ? <view>收件箱
? ? ? ? ? ? </view>
? ? ? ? ? ? </view>
? ? ? ? ? ? <view class="nav_left_items {{click == 2 ? 'active' : ''}}"?
? ? ? ? ? bindtap="switchRightTab" ?data-id="2">
? ? ? ? ? ? ? ? <image ? class='icon' src='../../images/send.png'></image>
? ? ? ? ? ? ? ? <view>發(fā)件箱
? ? ? ? ? ? </view>
? ? ? ? ? ? </view>
? ? ? ? ? ? <view class="nav_left_items {{click == 3 ? 'active' : ''}}"?
? ? ? ? ? bindtap="switchRightTab" ?data-id="3">
? ? ? ? ? ? ? ? <image ? class='icon' src='../../images/write.jpg'></image>
? ? ? ? ? ? ? ? <view >寫信件
? ? ? ? ? ? </view>
? ? ? ? </view>
</scroll-view>

.js文件

?tap_ch: function(e) {
? ? if (this.data.open) {
? ? ? ? this.setData({
? ? ? ? ? ? open: false
? ? ? ? });
? ? } else {
? ? ? ? this.setData({
? ? ? ? ? ? open: true
? ? ? ? });
? ? }
},
tap_start: function(e) {
? ? // touchstart事件
? ? // 把手指觸摸屏幕的那一個點的 x 軸坐標賦值給 mark 和 newmark
? ? this.data.mark = this.data.newmark = e.touches[0].pageX;
},

tap_drag: function(e) {
? ? // touchmove事件
? ? this.data.newmark = e.touches[0].pageX;
? ?
? ? // 手指從左向右移動
? ? if (this.data.mark < this.data.newmark) {
? ? ? ? this.istoright = true;
? ? }
? ??
? ? // 手指從右向左移動
? ? if (this.data.mark > this.data.newmark) {
? ? ? ? this.istoright = false;
? ? }
? ? this.data.mark = this.data.newmark;
},

tap_end: function(e) {
? ? // touchend事件
? ? this.data.mark = 0;
? ? this.data.newmark = 0;
? ? // 通過改變 opne 的值,讓主頁加上滑動的樣式
? ? if (this.istoright) {
? ? ? ? this.setData({
? ? ? ? ? ? open: true
? ? ? ? });
? ? } else {
? ? ? ? this.setData({
? ? ? ? ? ? open: false
? ? ? ? });
? ? }
},

.wxss文件

.nav_left{
? ? width:25%;
? ? height:100%;
? ? background:#F2F2F2;
? ? text-align:center;
? ? position:absolute;
? ? top:0;
? ? left:0;
? }
? .nav_left .nav_left_items{
? ? ? display: flex;
? ? height:40px;
? ? line-height:40px;
? ? font-size:28rpx;
? }
? .nav_left .nav_left_items.active{
? ? ? display: flex;
? ? background: #fff; ?/* 背景色變成白色 */ ?
? color: #3385ff; ? ?/* 字體編程藍色 */
? border-left: 3px solid #3385ff; ?/* 設置邊框的寬度以及顏色 */
? }
.title{
? ? margin-top: 10px;
}
.icon{
? ? display: flex;
? ? justify-content: center;
? ? align-items: center;
? ? width:20px;
? ? height: 20px;
? ? margin: 0px 3px;
? ? border-radius: 5px ;
? ? margin-top:10px ;?
}
.headPortrait{
? ? width:28px;
? ? height: 28px;
? ? border-radius: 20px;
}
.page-slidebar {
? height: 100%;
? width: 750rpx;
? position: fixed;
? background-color:white;
? z-index: 0;
}

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

相關文章

  • JS仿Windows實現(xiàn)桌面主題特效

    JS仿Windows實現(xiàn)桌面主題特效

    這篇文章主要介紹了如何利用HTML+CSS+JS模仿Windows實現(xiàn)桌面主題特效,文中的示例代碼講講詳細,感興趣的小伙伴可以跟隨小編一起學習一下
    2022-06-06
  • 如何使用Javascript中的this關鍵字

    如何使用Javascript中的this關鍵字

    本文介紹了如何使用Javascript中的this關鍵字,文中代碼簡單易懂,對大家的學習或工作有一定幫助,需要的朋友可以參考下
    2020-05-05
  • 深入理解JavaScript中的傳值與傳引用

    深入理解JavaScript中的傳值與傳引用

    這篇文章主要是對JavaScript中的傳值與傳引用進行了詳細的介紹,需要的朋友可以過來參考下,希望對大家有所幫助
    2013-12-12
  • 解決webpack dev-server不能匹配post請求的問題

    解決webpack dev-server不能匹配post請求的問題

    這篇文章主要介紹了解決webpack不能匹配post請求的問題,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • javascript:void(0)使用探討

    javascript:void(0)使用探討

    如果想做一個鏈接點擊后不做任何事情,或者響應點擊而完成其他事情一般都是設置屬性href = "#"其實還有比這更好的方法,下面為大家整理了幾種比較常見的解決方法,感興趣的朋友可以參考下
    2013-08-08
  • element-ui上傳一張圖片后隱藏上傳按鈕功能

    element-ui上傳一張圖片后隱藏上傳按鈕功能

    這篇文章主要介紹了element-ui上傳一張圖片后隱藏上傳按鈕功能,本文通過實例代碼給大家介紹的非常詳細,具有一定的參考借鑒價值 ,需要的朋友可以參考下
    2019-05-05
  • Javascript的表單驗證-提交表單

    Javascript的表單驗證-提交表單

    JavaScript 可用來在數(shù)據(jù)被送往服務器前對 HTML 表單中的這些輸入數(shù)據(jù)進行驗證。通過本文給大家介紹Javascript的表單驗證-提交表單,對javascript表單驗證,提交表單相關知識感興趣的朋友一起學習吧
    2016-03-03
  • 移動端腳本框架Hammer.js

    移動端腳本框架Hammer.js

    這篇文章主要為大家詳細介紹了一款開源的移動端腳本框架Hammer.js,可以完美的實現(xiàn)在移端開發(fā)的大多數(shù)事件,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • JavaScript使用prototype定義對象類型(轉)[

    JavaScript使用prototype定義對象類型(轉)[

    JavaScript使用prototype定義對象類型(轉)[...
    2006-12-12
  • JavaScript小技巧整理篇(非常全)

    JavaScript小技巧整理篇(非常全)

    這篇文章主要介紹了JavaScript小技巧整理篇(非常全)的相關資料,需要的朋友可以參考下
    2016-01-01

最新評論