vue 底部导航状态改变

 

HTML:

<div class="footer">
   	<div class="footer-nav" v-for="(item, index) in footer" @click="switchTo(index)">
   		<img v-if="index == idx" :src="item.active_url">
   		<img v-else :src="item.url">
   	</div>
</div>

script:

export default {
  name: 'App',
  data () {
  	return {
  		footer: [{
  			url: require("./assets/images/01.png"),
  			active_url: require("./assets/images/01_1.png"),
  			path: "/home"
  		},{
  			url: require("./assets/images/02.png"),
  			active_url: require("./assets/images/02_2.png"),
  			path: "/shop"
  		},{
  			url: require("./assets/images/03.png"),
  			active_url: require("./assets/images/03_3.png"),
  			path: "/login"
  		}],
  		idx: 0
  	}
  },

  methods: {
  	switchTo: function(i) {
  		var _this = this;
  		_this.idx = i;
  		_this.$router.replace(_this.footer[i].path)
  		console.log(i,this.footer[i].path)
  	}
  }
};

css:

#app{	
	position: relative;
	.nav {
		height: px2rem(98px);
		width: 100%;
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		border-top: 1px solid #e7e7e7;
		display: flex;
		justify-content: space-around;
		align-items: center;
		.nav-list{
			width: 100%;
			height: 100%;
			display: flex;
			align-items: center;
			img{
				width: px2rem(50px);
				height: px2rem(50px);
				display: block;
				margin: 0 auto;
			}
		}
	}
}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值