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

微信小程序MUI側(cè)滑導(dǎo)航菜單示例(Popup彈出式,左側(cè)滑動(dòng),右側(cè)不動(dòng))

 更新時(shí)間:2019年01月23日 09:56:23   作者:Rattenking  
這篇文章主要介紹了微信小程序MUI側(cè)滑導(dǎo)航菜單,結(jié)合實(shí)例形式分析了微信小程序Popup彈出式,左側(cè)滑動(dòng),右側(cè)不動(dòng)菜單功能相關(guān)實(shí)現(xiàn)技巧與注意事項(xiàng),需要的朋友可以參考下

本文實(shí)例講述了微信小程序MUI側(cè)滑導(dǎo)航菜單。分享給大家供大家參考,具體如下:

實(shí)現(xiàn)的目標(biāo)MUI的off canvas效果

點(diǎn)擊列表 —- 右側(cè)展示頁(yè)面不動(dòng),左側(cè)導(dǎo)航滑動(dòng) —- 點(diǎn)擊右側(cè)遮罩層或者左側(cè)選項(xiàng) —- 左側(cè)還原,右側(cè)去掉遮罩層

實(shí)現(xiàn)方案2:左右分上下兩層,左側(cè)滑動(dòng),右側(cè)不動(dòng)

 

WXML

<view class="page">
 <view class="page-top {{open ? 'page-top-show' : ''}}">
  <view class="nav-list" wx:for-items="{{nav_list}}" bindtap="open_list" data-title="{{item}}">
   <text>{{item}}</text>
  </view>
 </view>
 <view class="page-bottom">
  <image class="off-nav-list" bindtap="off_canvas" src="../../images/btn.png"></image>
  <view class="page-bottom-content">
   <text>{{text}}</text>
  </view>
  <view class="page-mask {{open ? '' : 'page-mask-hide'}}" bindtap="off_canvas"></view>
 </view>
</view>

WXSS

page,.page {
 height: 100%;
 font-family: 'PingFang SC', 'Helvetica Neue', Helvetica, 'Droid Sans Fallback', 'Microsoft Yahei', sans-serif;
}
/*左側(cè)導(dǎo)航 */
.page-top{
 position: fixed;
 width: 75%;
 height: 100%;
 top: 0;
 left: 0;
 background-color: rgb(0, 68, 97);
 transform: rotate(0deg) scale(1) translate(-100%,0%);
 -webkit-transform: rotate(0deg) scale(1) translate(-100%,0%);
 transition: all 0.4s ease;
 z-index: 998;
}
.page-top-show{
 transform: rotate(0deg) scale(1) translate(0%,0%);
 -webkit-transform: rotate(0deg) scale(1) translate(0%,0%);
}
.nav-list{
 padding: 30rpx 0 30rpx 40rpx;
 color:#fff;
}
/*右側(cè)展示 */
.page-bottom{
 height: 100%;
 background-color: rgb(57, 125, 230);
 position: relative;
}
.off-nav-list{
 position: fixed;
 width: 60rpx;
 height: 50rpx;
 top: 20rpx;
 left:20rpx;
}
.page-bottom-content{
 padding:100rpx 20rpx 30rpx;
 color: #fff;
}
.page-mask{
 width: 100%;
 height: 100%;
 background-color:rgba(0,0,0,0.5);
 position: absolute;
 top: 0;
 left: 0;
 z-index: 10;
}
.page-mask-hide{
 display: none;
}

JS

var app = getApp();
var data = require('../../utils/data.js');
Page({
 /**
  * 頁(yè)面的初始數(shù)據(jù)
  */
 data: {
  text: 'ES6學(xué)習(xí)之路',
  nav_list: ['ES6學(xué)習(xí)之路', 'CSS特效', 'VUE實(shí)戰(zhàn)','微信小程序'],
  open: false
 },
 //列表的操作函數(shù)
 open_list: function(opts){
  this.setData({ text: opts.currentTarget.dataset.title,open: false});
 },
 //左側(cè)導(dǎo)航的開(kāi)關(guān)函數(shù)
 off_canvas: function(){
  this.data.open ? this.setData({open: false}) :this.setData({open: true});
 }
})

總結(jié):

1. 代碼簡(jiǎn)化:off_canvas函數(shù)簡(jiǎn)化代碼,采用三目表達(dá)式,簡(jiǎn)單切清晰;

2. 渲染:注意對(duì)data對(duì)象中屬性進(jìn)行賦值時(shí),要采用this.setData()方法,否則屬性改變不會(huì)重新渲染(eg:this.data.text = opts.currentTarget.dataset.title;)這樣text的值改變,頁(yè)面不會(huì)重新渲染text;

3. 代碼簡(jiǎn)化:this.data.open ? this.setData({open: false}) :this.setData({open: true});簡(jiǎn)化為this.setData({ open: this.data.open ? false : true});

希望本文所述對(duì)大家微信小程序開(kāi)發(fā)有所幫助。

相關(guān)文章

最新評(píng)論