当前位置: 首页 > article >正文

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

文章目录

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

1. 自定义tabbar效果

请添加图片描述

2. pages新建tabbar页面

  1. 首先在 pages.json 文件中,新建一个 tabbar 页面
"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 样式文件太多了就不贴出来了
<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>


http://www.kler.cn/a/153473.html

相关文章:

  • 电梯导航的小练习
  • 【漏洞复现】大华智慧园区综合管理平台deleteFtp接口远程命令执行
  • 解决git action发布报错:Input required and not supplied: upload_url
  • 手机上的记事本怎么打开?安卓手机通用的记事本APP
  • SVG图片选择库组件封装及使用
  • 企业真题(数组\面向对象-基础)
  • 智慧安防三大信息技术:云计算、大数据及人工智能在视频监控EasyCVR中的应用
  • 华为OD机试真题-最大坐标值-2023年OD统一考试(C卷)
  • 一起学docker系列之十五深入了解 Docker Network:构建容器间通信的桥梁
  • Servlet概念视频笔记
  • 播放器开发(七):音视频同步实现
  • Linux:vim的简单使用
  • JavaScript 内存泄漏的检测与防范:让你的程序更稳定
  • PTA 7-188 水仙花数
  • 计算机网络——数据链路层-封装成帧(帧定界、透明传输-字节填充,比特填充、MTU)
  • centos上安装并持久化配置LVS
  • 深度学习今年来经典模型优缺点总结,包括卷积、循环卷积、Transformer、LSTM、GANs等
  • 关于前端的学习思考-父子盒子溢出问题
  • 山西电力市场日前价格预测【2023-12-02】
  • wordpress安装之Linux ftp传输