vue tab 切换

13 篇文章 0 订阅
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
<script src="https://cdn.bootcss.com/vue/2.4.2/vue.min.js"></script>
<style>
	*{margin:0;padding: 0;}
	.wrap{width:100%;}
	.wrap .nav{width:1200px;background: #c1c1c1;height:50px;margin:0 auto}
	.active{background:#fff;color:red;font-weight: bold;}
	.wrap .nav li{margin-left:230px;display: inline-block;line-height: 50px;padding:0 10px;cursor: pointer;}
	.div1{width:1200px;height:400px;background: yellow;margin:0 auto;margin-top:20px}
	.div2{width:1200px;height:400px;background: pink;margin:0 auto;margin-top:20px}
	.div3{width:1200px;height:400px;background: purple;margin:0 auto;margin-top:20px}
</style>
</head>
<body>
<div id="total" class="wrap">
	<ul class="nav">
		<li @click="change(1)" v-bind:class="flag==1?'active' : ''">三角形</li>
		<li @click="change(2)" v-bind:class="flag==2?'active' : ''">图片轮播</li>
		<li @click="change(3)" v-bind:class="flag==3?'active' : ''">下拉菜单</li>
	</ul>
	<div class="div1" v-if="flag==1"></div>
	<div class="div2" v-if="flag==2"></div>
	<div class="div3" v-if="flag==3"></div>
</div>
<script>
	new Vue({
	 el:'#total',
	 data:{
	 	flag:1,
	 },
	 methods:{
	 	change:function(a){
	 		this.flag=a;
	 	}
	 }
	})
</script>
</body>
</html>
vue高效导航切换以及class属性切换
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值