Commit f755133f by 李伟康

navBar增加返回按钮

1 parent d0696dbe
......@@ -6,6 +6,7 @@ Component({
properties: {
navStyle: String,
custom: Boolean,
showBack: Boolean,
pageTitle: {
type: String,
value: '',
......@@ -47,8 +48,13 @@ Component({
width,
top
} = wx.getMenuButtonBoundingClientRect(),
currentPages = getCurrentPages()
currentPages = getCurrentPages(), {
showBack
} = this.data
if (showBack && currentPages.length > 1) this.setData({
SHOWBACK: true
})
console.log(currentPages.length, showBack)
let navigationBarHeight = height + ((top - statusBarHeight) * 2) + 4 // 4
let navigationBarPadding = screenWidth - right
let navigationBarWidth = screenWidth - (navigationBarPadding * 2 + width) - width
......@@ -81,6 +87,9 @@ Component({
navHeight,
statusBarHeight
})
},
back() {
wx.$router.back()
}
},
lifetimes: {
......
<view class="navigation-bar" id="navigation-bar"
style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<view class="navigation-bar" id="navigation-bar" style="padding-top:{{statusBarHeight}}px;height:{{navigationBarHeight}}px;{{navStyle}}">
<block wx:if="{{!custom}}">
<view class="navigation-bar-box" wx:if="{{showNavBar}}" style="{{navigationBarStyle}}">
<block wx:if="{{SHOWBACK}}">
<view class="back" bindtap="back">
<image src="./images/icon-back.png"></image>
</view>
</block>
<view class="navigation-bar-titleText" style="{{navigationBarTextWidth}}">
<slot></slot>
</view>
......
......@@ -36,9 +36,9 @@
}
.back{
position: absolute;
left: 20rpx;
left: 44rpx;
top: 50%;
transform: translateY(-50%);
width: 36rpx;
height: 36rpx;
width: 16rpx;
height: 34rpx;
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!