uni-app 微信小程序之自定义中间圆形tabbar

文章目录

  • [1. 自定义tabbar效果](#1. 自定义tabbar效果)
  • [2. pages新建tabbar页面](#2. pages新建tabbar页面)
  • [3. tabbar 页面结构](#3. tabbar 页面结构)
  • [4. tabbar 页面完整代码](#4. tabbar 页面完整代码)

1. 自定义tabbar效果

2. pages新建tabbar页面

  1. 首先在 pages.json 文件中,新建一个 tabbar 页面
js 复制代码
"pages": [ //pages数组中第一项表示应用启动页,参考:https://uniapp.dcloud.io/collocation/pages
	{
		"path": "pages/index/tabbar",
		"style": {
			"navigationBarTitleText": "tabbar页面",
			"navigationStyle": "custom"
		}
	},
	.....// 其他页面
],

3. tabbar 页面结构

  1. 此页面主要是写 tabbar的html样式和布局,引用主页面代码,通过 v-if 控制进行展示 indexsearchmaimnewsme 一级页面

4. tabbar 页面完整代码

  1. css 样式文件太多了就不贴出来了
html 复制代码
<template>
	<view>
		<index  v-if="PageCur=='index'"></index>
		<search v-if="PageCur=='search'"></search>
		<news v-if="PageCur=='news'"></news>
		<me v-if="PageCur=='me'"></me>
		
		<view class="box">
			<view class="cu-bar tabbar bg-white shadow foot">
				<view class="action" @click="NavChange" data-cur="index">
					<view class='cuIcon-cu-image'>
						<image v-if="PageCur=='index'" src="../../static/tabBar/index_cur.png"></image>
						<image v-if="PageCur != 'index'" src="../../static/tabBar/index.png"></image>
					</view>
					<view :class="PageCur=='index'?'color_main':'text-gray'">首页</view>
				</view>

				<view class="action" @click="NavChange" data-cur="search">
					<view class='cuIcon-cu-image'>
						<view class="cu-tag badge"></view>
						<image v-if="PageCur=='search'" src="../../static/tabBar/shop_cur.png"></image>
						<image v-if="PageCur != 'search'" src="../../static/tabBar/shop.png"></image>
					</view>
					<view :class="PageCur=='search'?'color_main':'text-gray'">会员专区</view>
					
				</view>
<view @click="NavChange" class="action text-gray add-action" data-cur="main">
					<image class="logo_btn" mode="widthFix" src="../../static/logo.png"></image>
					<view :class="PageCur=='main'?'color_main':'text-gray'">组件模板</view>
				</view>

				<view class="action" @click="NavChange" data-cur="news">
					<view class='cuIcon-cu-image'>
						<view class="cu-tag badge">{{message}}</view>
						<image v-if="PageCur=='news'" src="../../static/tabBar/order_cur.png"></image>
						<image v-if="PageCur != 'news'" src="../../static/tabBar/order.png"></image>
					</view>
					<view :class="PageCur=='news'?'color_main':'text-gray'">文章资讯</view>
				</view>

				<view class="action" @click="NavChange" data-cur="me">
					<view class='cuIcon-cu-image'>
						<image v-if="PageCur=='me'" src="../../static/tabBar/me_cur.png"></image>
						<image v-if="PageCur != 'me'" src="../../static/tabBar/me.png"></image>
					</view>
					<view :class="PageCur=='me'?'color_main':'text-gray'">个人中心</view>
				</view>

			</view>
		</view>

	</view>
</template>

<script>
	import index from "./index.vue";	//首页
	import search from "./search.vue";	//会员专区
	import main from "./main.vue";	//组件模板
	import news from "./news.vue";	//文章咨询
	import me from "./me.vue";	//个人中心
	export default {
		components: {
			index,
			search,
			main,
			news,
			me
		},
		data() {
			return {
				PageCur: 'index',
				message: '99+',
				duration:1
			};
		},
		methods: {
			NavChange: function(e) {
				this.PageCur = e.currentTarget.dataset.cur;
			},
		}
	}
</script>

<style lang="scss">
	// 省略
</style>
相关推荐
2401_845937533 小时前
PHP一键约课高效健身智能健身管理系统小程序源码
微信·微信小程序·小程序·微信公众平台·微信开放平台
程序员入门进阶5 小时前
基于微信小程序的科创微应用平台设计与实现+ssm(lw+演示+源码+运行)
微信小程序·小程序
鸭子嘎鹅子呱8 小时前
uniapp使用高德地图设置marker标记点,后续根据接口数据改变某个marker标记点,动态更新
uni-app·map·高德地图
计算机源码社12 小时前
分享一个基于微信小程序的居家养老服务小程序 养老服务预约安卓app uniapp(源码、调试、LW、开题、PPT)
android·微信小程序·uni-app·毕业设计项目·毕业设计源码·计算机课程设计·计算机毕业设计开题
双普拉斯15 小时前
微信小程序点赞动画特效实现
nginx·微信小程序·notepad++
程序员阿龙15 小时前
【2025】基于微信小程序的网上点餐系统设计与实现、基于微信小程序的智能网上点餐系统、微信小程序点餐系统设计、智能点餐系统开发、微信小程序网上点餐平台设计
微信小程序·小程序·毕业设计·订单管理·在线点餐·订单跟踪·在线支付
Angus-zoe15 小时前
uniapp+vue+微信小程序实现侧边导航
vue.js·微信小程序·uni-app
Pluto & Ethereal16 小时前
uni-app尺寸单位、flex布局于背景图片
uni-app
天空下sky1 天前
uniapp+若依 开发租房小程序源码分享
uni-app
帅过二硕ฅ1 天前
uniapp点击跳转到对应位置
前端·javascript·uni-app