Vue开发Tabs组件

该博客展示了一个使用Vue.js编写的组件,实现了左侧列表点击后,右侧显示相应内容的效果。通过`v-for`指令遍历数据列表,`v-show`控制元素的显示与隐藏,以及事件监听来更新当前选中项。页面布局采用浮层样式,提供了平滑的过渡效果。
摘要由CSDN通过智能技术生成
<template>
	<div class="container">
		<div class="left">
			<ul>
				<li v-for="(item,index) in datalist" @click="clickItem(index)" :key="index">{{item.text}}</li>
			</ul>
		</div>
		<div class="right">
			<div v-for="(item,index) in datalist" v-show="index===currentIndex" :key="index">{{index}}</div>
		</div>

		
	
		
	</div>
</template>

<script>
	export default{
		props:{},
		data(){
			return{
				datalist:[
					{
						id:1,
						text:'北京'
					},
					{
						id:2,
						text:'南京'
					},
					{
						id:3,
						text:'西安'
					}
				],
				currentIndex:0,
				pupShowL:false,
				
			}
		},
		components:{},
		methods:{
			clickItem(index){
				this.currentIndex = index
			},
			
		},
		mounted(){},
		created(){},
		watch:{}
	}
</script>

<style scoped lang="scss">
	.container{
		width: 500px;
		height: 600px;
		border: 1px solid red;
		.left{
			float: left;
			width: 30%;
			height: 100%;
			ul{
				li{
					width: 100%;
					height: 30px;
					transition: all 0.2s ease;
					line-height: 30px;
					cursor: pointer;
					&:hover{
						background-color: #EEEEEE;
					}
				}
			}
		}
		.right{
			position: relative;
			float:right;
			width: 70%;
			height: 100%;
				
			div{
				position: absolute;
				width: 100%;
				height: 100%;
			}
		}
		.pup{
			
			margin-left: 40px;
			width: 60px;
			
			background-color: red;
			height: 50px;
			transition: height 0.1s ease;
		}
	}
	
	
</style>

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值