微信小程序 界面从右边滑出_微信小程序MUI侧滑导航菜单示例(Popup弹出式,左侧不动,右侧滑动)...
本文實(shí)例講述了微信小程序MUI側(cè)滑導(dǎo)航菜單。分享給大家供大家參考,具體如下:
實(shí)現(xiàn)的目標(biāo)—-YDUI的Popup組件
點(diǎn)擊列表圖標(biāo)—-左側(cè)的菜單欄顯示—-點(diǎn)擊關(guān)閉按鈕或者右側(cè)的遮罩層—-左側(cè)菜單欄關(guān)閉
實(shí)現(xiàn)方案1:左側(cè)菜單和右側(cè)展示頁面分為上下兩層
wxml
{{item}}
autoplay="{{autoplay}}" interval="{{interval}}" duration="{{duration}}"
indicator-color="#fff" indicator-active-color="red">
wxss
page,.page {
height: 100%;
font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, 'Droid Sans Fallback', 'Microsoft Yahei', sans-serif;
}
/*左側(cè)導(dǎo)航列表 */
.page-bottom{
height: 100%;
width: 75%;
position: fixed;
background-color: rgb(0, 68, 97);
z-index: 0;
}
.page-list{
color: white;
padding: 30rpx 0 30rpx 40rpx;
}
/*右側(cè)展示層 */
.page-top{
position: relative;
top: 0;
left:0;
width: 750rpx;
height: 100%;
background-color: rgb(57, 125, 230);
z-index: 0;
transition: All 0.4s ease;
-webkit-transition: All 0.4s ease;
}
.page-state{
transform: rotate(0deg) scale(1) translate(75%,0%);
-webkit-transform: rotate(0deg) scale(1) translate(75%,0%);
}
.imgw{width:100%;}
/*右側(cè)列表按鈕 */
.page-top .left-nav{
position: fixed;
width: 68rpx;
height: 38rpx;
left: 20rpx;
bottom: 20rpx;
}
/*右側(cè)遮罩層 */
.page-mask{
position: absolute;
width: 100%;
height: 100%;
top: 0;
left: 0;
background-color: rgba(0,0,0,0.5);
z-index: 998;
}
.page-mask-show{
display: none;
}
js
var app = getApp();
var data = require('../../utils/data.js');
Page({
/**
* 頁面的初始數(shù)據(jù)
*/
data: {
banner_url: data.bannerList(),
nav_list: ['ES6學(xué)習(xí)之路', 'CSS特效', 'VUE實(shí)戰(zhàn)','微信小程序'],
open: false,
indicatorDots: true,//是否顯示面板指示點(diǎn)
autoplay: true,//是否開啟自動(dòng)切換
interval: 3000,//自動(dòng)切換時(shí)間間隔
duration: 500//滑動(dòng)動(dòng)畫時(shí)長
},
//列表的操作函數(shù)
open_list: function(){
//此處進(jìn)行操作
this.setData({
open: false
});
},
//左側(cè)導(dǎo)航的開關(guān)函數(shù)
offCanvas: function(){
if(this.data.open){
this.setData({
open: false
});
}else{
this.setData({
open: true
});
}
}
})
總結(jié):
1. 右側(cè)展示的動(dòng)畫,我們可以直接通過class將其統(tǒng)一定義完整,然后通過切換class來改變動(dòng)畫的控制—-減少了js對(duì)dom中style的操作。
2. 在左側(cè)菜單導(dǎo)航操作的最后記得open=false,使頁面還原。
DEMO源碼
點(diǎn)擊此處本站下載。
希望本文所述對(duì)大家微信小程序開發(fā)有所幫助。
總結(jié)
以上是生活随笔為你收集整理的微信小程序 界面从右边滑出_微信小程序MUI侧滑导航菜单示例(Popup弹出式,左侧不动,右侧滑动)...的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: (二叉树的动态创建与bfs)树的层次遍历
- 下一篇: 2021年香河一中高考成绩查询,2021