vue 底部导航组件

不喜欢罗里吧嗦,拿过去直接能用:

<template>
    <div class="footer">
		<div v-for='(item,index) of items' :class='[item.cls,{on:index === idx}]' @click="$router.push(item.push)" :key='index'>
			<img class="img" :src="index===idx?item.iconSelect:item.icon">
			<p :class="['colorChange',{on:index===idx}]" >{{item.name}}</p>
		</div>
 
	</div>
</template>
<script>
export default{
		props:['idx'],
		data(){
			return {
				items:[
				{
					cls:"myCourse",
					push:"/myCourse",
					icon:'stiao-26.png',
					iconSelect:'stiao-23.png'
        },
        {
					cls:"myCourse",
					push:"/",
					icon:'stiao-25.png',
					iconSelect:'stiao-22.png'
				},
				{
					cla:"mine",
					push:"/myCenter",
					icon:'stiao-24.png',
					iconSelect:'stiao-21.png'
				}]
			}
		}
	} 

</script>
<style lang="scss" scope>
.footer{
	font-size: .24rem ;
  color:red;
  position: fixed;
  bottom: 0;
  width: 100%;
  height:1rem ;
  display: flex;
  border-top: 1px #f2f2f2 solid;
  }
	div{
		flex: 1;
	}
	div img{
		width: 1.08rem;
    margin: 0 auto;
    height: .80rem;
    flex: 1;
    margin-top: .1rem;
	}
</style>

组件写好后,直接引入

 <public-footer :idx="1"></public-footer>

啰嗦一句,idx是用来判断到了哪个页面的参数

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值