uni-app自定义底部切换栏tabBar

<template>
	<view class="footer-bar">
		<view class="bar-list">
			<view class="bar-item" :class="item.active?'bar-item-active':''" v-for="(item,index) in listData" :key="index" @click="tabClick(item.url)">
				<image :src="item.image" class="item-icon"></image>
				{{item.name}}
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				
			};
		},
		props:{
			listData:{
				type:Array,
				value:[]
			}
		},
		methods:{
			tabClick: function(url){
				uni.navigateTo({
					url: url
				})
			}
		}
	}
</script>

<style lang="scss">
	.footer-bar {
		.bar-list {
			width: 100%;
			height: 100rpx;
			position: fixed;
			bottom: 0;
			left: 0;
			display: flex;
			justify-content: space-around;
			align-items: center;
			background:rgba(255,255,255,1);
			box-shadow:0px 0px 0px 0px rgba(0,0,0,0.1);
			
			.bar-item{
				text-align: center;
				font-size:20rpx;
				font-family:PingFangSC-Regular,PingFang SC;
				font-weight:400;
				color:rgba(50,60,73,1);
				text-align: center;
				
				.item-icon{
					display: block;
					width: 44rpx;
					height:44rpx;
					margin: 0 auto 8rpx auto;
				}
			}
			
			.bar-item-active{
				color:rgba(102,166,255,1);
			}
		}
	}
</style>

 

引用:

import uiTabBar from '@/components/ui-tab-bar/ui-tab-bar.vue'

components: {
              uiTabBar
        }

listData: [{
                        name: '工作',
                        url: '../index/index',
                        image: '/static/image/gz_s.png',
                        active: true,
                    },
                    {
                        name: '功能',
                        url: '../function/function',
                        image: '/static/image/work.png',
                        active: false,
                    },
                    {
                        name: '通讯录',
                        url: '../book/book',
                        image: '/static/image/book.png',
                        active: false,
                    }, {
                        name: '我的',
                        url: '../myhome/myhome',
                        image: '/static/image/myhome.png',
                        active: false,
                    }
                ],

页面:  <ui-tab-bar :listData="listData"></ui-tab-bar>

 

效果:

 

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值