Browse Source

1111

master
wangjiahai 2 years ago
parent
commit
970ec148ce
  1. 88
      components/NavBar/NavBar.vue

88
components/NavBar/NavBar.vue

@ -1,13 +1,28 @@
<template>
<!-- 这里不使用props改用data -->
<view class="_navLayout" :style="{background: navBackground,'height':_height}">
<view :style="{'height':_height3}"></view>
<view class="_nav-real" :style="{'height':_height2}">
<view class="_navText">{{navTitle}}</view>
<image v-if="showIcon" class="_navIcon" src="../../static/wx_back.png" @click="clickIcon">
</image>
<view>
<!-- 居中布局 -->
<!-- 这里不使用props改用data -->
<view :v-if="style==='center'" class="_navLayout"
:style="{'background': navBackground,'height':navStatusHeight}">
<!-- 状态栏 -->
<view :style="{'height':statusBarHeight}"></view>
<!-- 导航栏,去掉了不可用的宽度 -->
<view class="_nav-real" :style="{'height':navHeight,'width':enableWidth}">
<!-- 按键区域占用为不可用的宽度 -->
<view class="_navIcon" :style="{'width':disableWidth,'height':navHeight}">
<image src="../../static/wx_back.png" style="width: 23px;height: 23px;"></image>
</view>
<!-- 标题布局 -->
<view class="_nav-title" :style="{'height':navHeight,'line-height':navHeight,'font-size':fontSize}">
{{navTitle}}
</view>
</view>
</view>
</view>
<view v-if="!supportChange" :style="{'height':navStatusHeight}"></view>
</template>
<script>
@ -15,10 +30,15 @@
* 全局默认背景透明supportChange= false 会对默认色变成不透明
*/
const defaultTransparentBg = "linear-gradient(89.26deg, rgba(254,144,56,0) 0.75%,rgba(255,177,118,0) 99.78%)";
let style = 'center'
export default {
name: "NavBar",
props: {
color: {
type: String,
default: "white"
},
//
navTitle: {
type: String,
@ -56,10 +76,13 @@
return {
// props
navBackground: this.navBg,
_height: '0px',
_height2: '0px',
_height3: '0px',
_right: '0px',
navStatusHeight: 0,
statusBarHeight: 0,
navHeight: 0,
disableWidth: 0,
enableWidth: 0,
enableHeight: 0,
fontSize: 0,
};
},
mounted() {
@ -77,10 +100,17 @@
// data
// script,使this使
let navInfo = getApp().globalData.navInfo
this._height = navInfo.navHeight
this._height2 = navInfo.navUseHeight
this._height3 = navInfo.statusBarHeight
this._right = navInfo.navPaddingRight
//
style = navInfo.navBar.style
//
this.navStatusHeight = navInfo.navStatusHeight + navInfo.unit
this.statusBarHeight = navInfo.statusBarHeight + navInfo.unit
this.navHeight = navInfo.navBar.height + navInfo.unit
this.disableWidth = navInfo.navBar.disableWidth + navInfo.unit
this.enableWidth = navInfo.navBar.enableWidth + navInfo.unit
this.enableHeight = navInfo.navBar.enableHeight + navInfo.unit
this.fontSize = navInfo.navBar.fontSize + navInfo.unit
console.log(this);
},
methods: {
/**
@ -117,33 +147,37 @@
}
</script>
<style scoped>
<style>
._navLayout {
display: flex;
flex-direction: column;
width: 100%;
position: fixed;
z-index: 999;
top: 0
top: 0;
position: fixed;
}
._nav-real {
display: flex;
flex-direction: row;
justify-content: center;
width: 100%;
align-items: center;
position: relative;
}
._navText {
font-size: 13px;
._nav-title {
text-align: center;
text-overflow: ellipsis;
overflow: hidden;
word-break: break-all;
white-space: nowrap;
width: 100%;
color: white;
}
._navIcon {
width: 23px;
height: 23px;
position: absolute;
left: 4px;
display: flex;
flex-direction: row;
align-items: center;
padding-left: 3px;
}
</style>
Loading…
Cancel
Save