效果图

隐藏小程序底部导航栏

封装组件

components 文件夹中新建一个 tabbar.vue 文件

<template><view class="tabbar"><view class="tarbar-list"><view class="barPart" @click="changPage(index)" v-for="(list , index) in tabBar.list" :key="index"><image :src="selected == index ? list.selectedIconPath : list.iconPath":style="{ bottom : index == 1 ? '30'+'rpx':'36'+'rpx', marginLeft : index == 1 ? '34'+'rpx':'42'+'rpx', width : list.iconWith+'rpx' , height : list.iconHeight+'rpx'}"></image><view :style='{color: selected == index ? tabBar.selectedColor : tabBar.color}'>{{list.text}}</view></view><view class="release" @click="toRelease"><image class="release_icon" src="../static/首页/icon_发布.png"></image></view></view></view>
</template><script>export default {data() {return {tabBar: {color: '#A9A9A9',selectedColor: '#000000',list: [{iconPath: "../static/首页/物品丢失.png",selectedIconPath: "../static/首页/物品丢失-1.png",text: '失物招领',pagePath: "/pages/index/index",iconWith: '50',iconHeight: '50',},{iconPath: "../static/首页/跑腿APP.png",selectedIconPath: "../static/首页/跑腿APP-1.png",text: '校园跑腿',pagePath: "/pages/errand/errand",iconWith: '64',iconHeight: '64',},]},selected: this.current,}},//接收父组件传来的参数props: {//参数名current: {type: [Number, String], //参数类型default: 0 //默认值},},methods: {changPage(index) {//页面跳转uni.switchTab({url: this.tabBar.list[index].pagePath,fail: (err) => {console.log(err);}})//改变选中下标this.selected = index;if (this.selected == index) {return}this.$emit('change', index)},// 点击发布toRelease() {uni.navigateTo({url: '/pages/release/release',})}},}
</script><style scoped lang="less">.tarbar-list {display: flex;align-items: flex-end;justify-content: space-between;padding: 0 48rpx;box-sizing: border-box;height: 100rpx;background-color: #fff;border-radius: 26px 26px 0px 0px;box-shadow: 0px -2px 6px 0px rgba(225, 225, 225, 40);position: fixed;bottom: 0;width: 100%;}.release {position: absolute;background: linear-gradient(180deg, rgba(68, 193, 175, 1) 0%, rgba(10, 206, 206, 0) 100%);border-radius: 50%;left: 50%;top: -16rpx;transform: translateX(-50%);width: 112rpx;height: 112rpx;display: flex;align-items: center;justify-content: center;.release_icon {display: block;width: 60rpx;height: 60rpx;transform: translateY(-6rpx);}}.barPart {width: 20%;font-size: 24rpx;}.barPart>view {text-align: center;}.barPart>image {bottom: 36rpx;position: fixed;margin-left: 40rpx;object-fit: cover;object-position: center;}
</style>

页面引入组件

引入组件:

import tabbar from "../../components/tabbar.vue"

通过父子组件传参改变跳转后页面的默认下标:

<!-- 自定义导航栏 -->
<tabbar :current="current"></tabbar>data() {return {current:0//默认下标}
},
components: {tabbar
},

uni-app 自定义导航栏相关推荐

  1. android 自定义标签导航栏,自定义导航栏app下载-自定义导航栏(Custom Navigation Bar) 安卓版v0.4.3-PC6安卓网...

    自定义导航栏(Custom Navigation Bar)app是款非常好用的实用工具,自定义导航栏能让你自己设置个性的导航栏,再也不用为单调的导航栏而发愁,独特且唯一,感兴趣的朋友就来下载自定义导航 ...

  2. uniapp自定义导航栏,高度,自定义组件

    设置自定义导航栏 :globalStyle 内 navigationStyle": "custom" 配置页面:pages.json "globalStyle& ...

  3. uniapp中自定义导航栏

    相信很多小伙伴在使用uniapp进行多端开发的时候呢,在面对一些奇葩的业务需求的时候,uniapp给我们提供的默认导航栏已经不能满足我们的业务需求了,这个时候就需要我们自己自定义导航栏使用啦. 当然u ...

  4. uni-app自定义导航栏

    有时我们需要对导航栏进行自定义,接下来就是对uni-app进行代码的编写 对于一些不是很复杂的顶部导航,当然使用原生导航栏实现是最佳选择 uni-app原生导航栏也能实现一些顶部自定义按钮+搜索框,只 ...

  5. 微信小程序自定义导航栏完整适配方案

    写这篇博客的背景 临近节日,产品想给小程序首页头部设置图片背景,这个只能自定义导航栏来实现 当然除了自定义背景图,还可以放置其他组件,按钮.搜索框等 实践部分设备状态栏.胶囊.间距的高度(仅供参考)( ...

  6. 修改自定义导航栏按钮文字内容的方法

    第一步在 pages.json 内部定义 原生导航栏搜索框和按钮 {"path": "pages/tabbar/dingdan/dingdan","s ...

  7. 使用uniapp编译多端,自定义导航栏高度、状态栏的高度

    使用uniapp框架编译多端,在使用自定义导航栏的时候需要适配不同手机,在安卓和ios上手机的状态栏高度是不一样的,尤其是小程序. uni.getSystemInfo(); //在小程序上使用这个方法 ...

  8. 微信小程序 自定义导航栏,只保留右上角胶囊按钮

    微信小程序开发交流qq群   173683895    承接微信小程序开发.扫码加微信. navigationStyle 导航栏样式,仅支持以下值: default 默认样式 custom 自定义导航 ...

  9. iOS个人中心渐变动画、微信对话框、标签选择器、自定义导航栏、短信验证输入框等源码...

    iOS精选源码 简单的个人中心页面-自定义导航栏并予以渐变动画 程序员取悦女票的正确姿势---Tip1(iOS美容篇) iOS 前台重启应用和清除角标的问题 微信原生提醒对话框3.0 JHLikeBu ...

最新文章

  1. php7搭建平台,在windows7中搭建Apache+PHP+MySQL平台
  2. 【转】The Google File System 中文版
  3. HTTP Status 405 - JSPs only permit GET POST or HEAD问题的分析和解决办法
  4. 买了又扔 戴尔放弃vworkspace虚拟桌面
  5. 视频编解码器常见问题介绍
  6. 项目NABCD的分析
  7. MPEG(mpeg1,mpeg2,mpeg4) 与H264 QP值间 关系
  8. java switch中if_详解java中if语句和switch的使用
  9. 【pytorch 】nn.init 中实现的初始化函数 normal, Xavier==》为了保证数据的分布(均值方差一致)是一样的,类似BN
  10. 大淘宝的终极商业阶段
  11. 线元法输入曲线要素_Origin入门教程(三):Origin中曲线怎么平移?
  12. Ubuntu下Gnome修改键盘映射
  13. 波士顿房价数据集 Boston house prices dataset
  14. 【mqtt】client测试工具使用
  15. wordpress入门主题_WordPress播客入门指南
  16. Linux系统学习环境搭建 - 跟小智一起学网络(3)
  17. Fragment如何实现左右分屏显示的
  18. mac连接android手机存储,Android安卓设备连接Mac的方法
  19. 联想拯救者Y7000重装win10系统卡在logo界面
  20. 计算机思维培训心得,2020参加计算机培训心得体会精选

热门文章

  1. Android 多窗口框架全解析
  2. 内存/闪存集体缺货涨价 原因竟是这?
  3. x in ‘Yy‘ == x in list(‘Yy‘)? ‘‘ 空字符串是任何字符串的子串
  4. Python3爬虫——爬取猫眼电影排行
  5. 我的世界怎么修改服务器刷怪率,《我的世界》地图刷怪率变高方法详解
  6. 【目标检测】YOLOv5 5.0调用摄像头报错的处理
  7. 实现一台服务器读取另一台远程服务器的文件
  8. 团队工作协议的一个例子
  9. 随着滚动条下拉,导航栏置顶
  10. windows电脑与苹果手机、ipad实现文件共享