微信小程序?qū)崿F(xiàn)左側(cè)滑動導(dǎo)航欄
本文實例為大家分享了微信小程序?qū)崿F(xiàn)左側(cè)滑動導(dǎo)航欄的具體代碼,供大家參考,具體內(nèi)容如下
左側(cè)滑動導(dǎo)航欄如圖

wxml
<!-- 左側(cè)滾動欄 -->
<view class='under_line'></view>
<view style='float: left' class='left'>
<scroll-view scroll-y scroll-with-animation scroll-left="{{scrollLength}}" class='scrollY' style='height: {{winHeight}}px'>
<view class='all clear'>
<block wx:key="lists" wx:for="{{lists}}">
<view bindtap='jumpIndex' data-menuindex='{{index}}'>
<view class='text-style'>
<text class="{{indexId==index?'active1':''}}">{{item}}</text>
<text class="{{indexId==index?'active':''}}"></text>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
wxss
.under_line{
width: 100%;
border-top: 1rpx solid #efefef;
}
.scrollY {
width: 200rpx;
position: fixed;
left: 0;
top: 0;
border-right: 1rpx solid #efefef;
}
.left {
border-top: 1rpx solid #efefef;
border-right: 1rpx solid #efefef;
}
.text-style {
width: 200rpx;
height: 140rpx;
line-height: 140rpx;
text-align: center;
font-size: 34rpx;
font-family: PingFangSC-Semibold;
color: rgba(51, 51, 51, 1);
}
.active1 {
color: #85d1fd;
}
.active {
display: block;
width: 50rpx;
height: 6rpx;
background: #85d1fd;
position: relative;
left: 75rpx;
bottom: 30rpx;
}
js
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
lists: [
"標(biāo)題1", "標(biāo)題二", "標(biāo)題三", "標(biāo)題四", "標(biāo)題五", "標(biāo)題六", "標(biāo)題七", "標(biāo)題八", "標(biāo)題九", "標(biāo)題十", "標(biāo)題十一", "標(biāo)題十二"
],
indexId: 0,
},
// 左側(cè)點擊事件
jumpIndex(e) {
let index = e.currentTarget.dataset.menuindex
let that = this
that.setData({
indexId: index
});
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面加載
*/
onLoad: function(options) {
var that = this
wx.getSystemInfo({
success: function(res) {
that.setData({
winHeight: res.windowHeight
});
}
});
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面顯示
*/
onShow: function() {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面隱藏
*/
onHide: function() {
},
/**
* 生命周期函數(shù)--監(jiān)聽頁面卸載
*/
onUnload: function() {
},
/**
* 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動作
*/
onPullDownRefresh: function() {
},
/**
* 頁面上拉觸底事件的處理函數(shù)
*/
onReachBottom: function() {
},
/**
* 用戶點擊右上角分享
*/
onShareAppMessage: function() {
}
})
更多教程點擊《Vue.js前端組件學(xué)習(xí)教程》,歡迎大家學(xué)習(xí)閱讀。
關(guān)于vue.js組件的教程,請大家點擊專題vue.js組件學(xué)習(xí)教程進(jìn)行學(xué)習(xí)。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Javascript showModalDialog兩個窗體之間傳值
前一篇文章Javascript怎么在兩個窗體之間傳值中講到了如何利用window.open()方法打開新窗體,并在兩個窗體之間傳值的方法。2009-09-09
Three.js使用OrbitControls后修改相機(jī)旋轉(zhuǎn)方向無效解決辦法
three.js是用javascript寫的基于webGL的第三方3D庫,下面這篇文章主要給大家介紹了關(guān)于Three.js使用OrbitControls后修改相機(jī)旋轉(zhuǎn)方向無效的解決辦法,文中通過代碼介紹的非常詳細(xì),需要的朋友可以參考下2024-01-01
React中如何使用echarts寫出3d旋轉(zhuǎn)扇形圖
這篇文章主要給大家介紹了關(guān)于React中如何使用echarts寫出3d旋轉(zhuǎn)扇形圖,介紹了如何使用React、TypeScript、Less和Echarts來構(gòu)建高效、可維護(hù)的前端應(yīng)用代碼結(jié)構(gòu),并提供了相關(guān)代碼示例,需要的朋友可以參考下2024-11-11
使用JavaScript獲取URL中的參數(shù)(兩種方法)
這篇文章主要介紹了使用JavaScript獲取URL中的參數(shù)(兩種方法)的相關(guān)資料,非常不錯,具有參考借鑒價值,需要的朋友可以參考下2016-11-11

