vue3 数据可视化大屏项目开发中,会需要一些tab切换组件,虽然已经有一些现成的组件了,这里整理的是vue3 数据可视化大屏tab组件-绿色边框组件。
使用组件
/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年05月30日16:09:52
* @Desc: 绿色tab组件
*/
<template>
<div class="tabs">
<div class="tab cur" :class="{active:active==item.id}" @click="getactive(item.id)" v-for="(item,index) in list"
:key="index">
<span>{{ item.name }}</span>
</div>
</div>
</template>
<script>
export default {
name: "tabs",
components: {},
props: {
list: {
type: Array,
default() {
return [];
}
},
active: {
type: [Number, String],
default() {
return 0;
}
},
},
data() {
return {}
},
watch: {},
mounted() {
},
methods: {
getactive(e) {
this.$emit('update:active', e)
},
}
}
</script>
<style scoped lang="scss">
.tabs {
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
.tab {
width: 120px;
height: 30px;
background: url("./assets/tabbg.png") center center no-repeat;
background-size: 100% 100%;
opacity: 1;
display: flex;
cursor: pointer;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
margin-right: 10px;
span {
font-size: 14px;
font-family: PingFang;
font-weight: 500;
color: #C8FBFB;
line-height: 60px;
opacity: 0.5;
}
}
.tab.active {
background: url("./assets/tabActivebg.png") center center no-repeat;
background-size: 100% 100%;
span {
opacity: 1;
color: #63F2FF;
}
}
}
</style>