Skip to content

Commit

Permalink
feat: pi-navbar支持默认显示
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangzhenfei committed Sep 19, 2020
1 parent 6ea36a6 commit d597495
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 9 deletions.
15 changes: 7 additions & 8 deletions components/pi-navbar/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,13 @@
:class="[
capsuleTheme,
{
'capsule pi-round':
capsuleButton && !$slots.left && showBack && isShowBack && showHome
'capsule pi-round': capsuleButton && !$slots.left && isShowBack && showHome
}
]"
>
<slot v-if="$slots.left" name="left" />
<template v-else>
<view
v-if="showBack && isShowBack"
class="pi-align-center back-wrap"
@tap="handleGoBack"
>
<view v-if="isShowBack" class="pi-align-center back-wrap" @tap="handleGoBack">
<view
:class="'pi-icon-' + backIconName"
:style="[
Expand Down Expand Up @@ -258,10 +253,14 @@ export default {
},
methods: {
syncPageRoute() {
/* eslint-disable */
if (this.showBack === undefined) {
/* eslint-disable */
const pages = getCurrentPages()
// 如果堆栈大于1表示打开了子页面,需要显示返回按钮
this.isShowBack = pages.length > 1
} else {
this.isShowBack = this.showBack
}
},
handleGoBack() {
// 如果自定义了点击返回按钮的函数,则执行,否则执行返回逻辑
Expand Down
2 changes: 1 addition & 1 deletion config/navbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default {
borderBottom: true, // 是否显示导航栏的下边框
statusBarBackground: 'transparent', // 状态栏的背景色
background: '#ffffff', // 背景颜色(默认白色)
showBack: true, // 是否显示后退按钮
showBack: undefined, // 是否显示后退按钮,默认不设置,根据当前页面堆栈自动判断
showHome: false, // 是否显示主页按钮
capsuleButton: true, // 在微信小程序中,当showBack和showHome同时显示的时候,以胶囊按钮样式显示
capsuleTheme: 'light', // 胶囊按钮主题, light or dark
Expand Down

0 comments on commit d597495

Please sign in to comment.