feat:重构按钮和icon组件
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
{
|
||||
"component": true
|
||||
"component": true,
|
||||
"styleIsolation": "apply-shared",
|
||||
"addGlobalClass": true
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@import '../../style/theme3.less';
|
||||
@import '../../style/theme.less';
|
||||
@import '../../assets/fonts/iconfont.less';
|
||||
|
||||
.nav-bar {
|
||||
position: fixed;
|
||||
@@ -22,6 +23,21 @@
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.nav-bar__back {
|
||||
width: 64rpx;
|
||||
height: 64rpx;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.nav-bar__back-icon {
|
||||
font-size: 40rpx;
|
||||
color: @color-nav-title;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.nav-bar__title {
|
||||
font-size: @fs-nav-title;
|
||||
font-weight: @fw-nav-title;
|
||||
@@ -41,4 +57,4 @@
|
||||
.nav-bar__placeholder {
|
||||
width: 100%;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
@@ -9,13 +9,25 @@ Component({
|
||||
data: {
|
||||
statusBarHeight: 0,
|
||||
navBlockHeight: 0,
|
||||
showBackButton: false,
|
||||
},
|
||||
lifetimes: {
|
||||
attached() {
|
||||
const { statusBarHeight } = wx.getWindowInfo();
|
||||
const pages = getCurrentPages();
|
||||
this.setData({
|
||||
statusBarHeight,
|
||||
navBlockHeight: statusBarHeight + NAV_INNER_PX,
|
||||
showBackButton: pages.length > 1,
|
||||
});
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
handleBack() {
|
||||
wx.navigateBack({
|
||||
fail: () => {
|
||||
wx.switchTab({ url: '/pages/home/home' });
|
||||
},
|
||||
});
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,5 +1,11 @@
|
||||
<view class="nav-bar" style="padding-top: {{statusBarHeight}}px; {{background ? 'background:' + background + ';' : ''}}">
|
||||
<view class="nav-bar__inner">
|
||||
<view
|
||||
wx:if="{{showBackButton}}"
|
||||
class="nav-bar__back"
|
||||
bindtap="handleBack">
|
||||
<text class="toy-icon toy-icon-arrow-left nav-bar__back-icon"></text>
|
||||
</view>
|
||||
<slot name="left"></slot>
|
||||
<text class="nav-bar__title">{{title}}</text>
|
||||
<view class="nav-bar__right">
|
||||
|
||||
Reference in New Issue
Block a user