uni-app 4.4封装头部导航组件
Posted 2019ab
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了uni-app 4.4封装头部导航组件相关的知识,希望对你有一定的参考价值。
index.nvue内容
<template>
<view class="">
<free-nav-bar :title="'微信(100)'" :fixed='true'>
<template v-slot="title"></template>
</free-nav-bar>
</view>
</template>
<script>
import freeNavBar from '@/components/free-ui/free-nav-bar.vue';
export default {
components: {
freeNavBar
},
data() {
return {
}
},
onLoad() {
},
methods: {
}
}
</script>
<style>
</style>
free-nav-bar.vue内容
<template>
<view>
<view class="bg-light" :class="fixed?'fixed-top':''">
<!-- 状态栏 -->
<view :style="'height:'+statusBarHeight+'px;'"></view>
<!-- 导航 -->
<view class="w-100 flex align-center justify-between" style="height: 90rpx;">
<!-- 左边 -->
<view class="flex align-center">
<!-- 标题 -->
<text v-if="title" class="font-md ml-3">{{title}}</text>
</view>
<!-- 右边 -->
<view class="flex align-center">
<free-icon-button @click="btn1"><text class="iconfont font-md"></text></free-icon-button>
<free-icon-button @click="btn2"><text class="iconfont font-md"></text></free-icon-button>
</view>
<!--\\ue6e3 \\ue682 -->
</view>
</view>
<!-- 站位 -->
<view v-if="fixed" :style="fixedStyle"></view>
</view>
</template>
<script>
import freeIconButton from './free-icon-button.vue';
export default {
components: {
freeIconButton,
},
props: {
title: {
type: String,
default: ''
},
fixed:{
type:Boolean,
default:false
}
},
data() {
return {
statusBarHeight: 0,
navBarHeight: 0,
}
},
mounted() {
// 获取任务栏高度
// #ifdef APP-PLUS-NVUE
this.statusBarHeight = plus.navigator.getStatusbarHeight()
// #endif
this.navBarHeight = this.statusBarHeight + uni.upx2px(90)
},
computed: {
fixedStyle() {
return `height:${this.navBarHeight}px`;
}
}
}
</script>
<style>
</style>
以上是关于uni-app 4.4封装头部导航组件的主要内容,如果未能解决你的问题,请参考以下文章
Android 4.4 — 半透明状态/导航栏 — fitSystemWindows/clipToPadding 不能通过片段事务工作