vue tab切换组件(带动画)笔记

vue tab切换组件(带动画)

个人备份而已

<template>
    <div>
        <div class="risk-tab-top">
            <div
                class="risk-active-line"
                :class="[activeIndex == 0?'risk-active-line-f':'risk-active-line-r']"
            />
            <div
                v-for="(item,index) in tabList "
                :key="index"
                class="risk-tab-cont p-12"
                :class="[activeIndex == index?'risk-active':'']"
                @click="tabChange(index)"
            >
                {{ item }}
            </div>
        </div>
    </div>
</template>

<script>
export default {
    name: 'IndexTab',
    components: {},
    mixins: [],
    props: {},
    data() {
        return {
            tabList: ['开票列表', '审核列表'],
            activeIndex: 0,
        };
    },
    methods: {
        tabChange(val) {
            this.activeIndex = val;
            this.$emit('switchTab',val);
        },
    },
};
</script>
<style lang="scss" scoped >
.risk-tab-top {
	color: rgba(138, 144, 155, 1);
	background: #f8f9fc;
	display: flex;
	flex-direction: row;
	width: 100%;
	position: relative;
	.risk-tab-cont {
		cursor: pointer;
		text-align: center;
		padding: 16px 32px;
		font-size: 16px;
		box-sizing: border-box;
	}
	.risk-active {
		color: #000;
		background: #fff;
	}
	.risk-active-line {
		width: 128px;
		height: 3px;
		background: rgba(76, 147, 255, 1);
		position: absolute;
		top:0px;
		transition: all 0.3s ease;
	}
	.risk-active-line-f {
		transform: translate3d(0px, 0, 0);
	}
	.risk-active-line-r {
		transform: translate3d(128px, 0, 0);
	}
}
.risk-cont {
	color: #000;
}
</style>
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值