vue3 数据可视化大屏项目开发中,会需要一些tab切换组件,虽然已经有一些现成的组件了,这里整理的是tab的蓝色描边ui组件。
使用实例
使用组件
/**
* @Author: 858834013@qq.com
* @Name: tab
* @Date: 2023年05月14日15:04:04
* @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;
width: calc(100% - 40px);
margin: 10px auto;
.tab {
width: 115px;
height: 60px;
margin-right: 12px;
background: url("./assets/tabbg.png") center bottom no-repeat;
background-size: 115px 20px;
opacity: 1;
display: flex;
cursor: pointer;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
span {
font-size: 20px;
font-family: Alibaba;
font-weight: normal;
color: #EEF3FF;
line-height: 19px;
background: linear-gradient(0deg, #8FB9F7 0%, rgba(255,255,255,0.87) 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
.tab.active {
width: 115px;
height: 60px;
background: url("./assets/tabbgActive.png") center bottom no-repeat;
background-size: 115px 20px;
opacity: 1;
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
align-content: flex-start;
span {
font-size: 20px;
font-family: Alibaba;
font-weight: normal;
color: #EEF3FF;
background: linear-gradient(0deg, #00F1FF 0%, #13ADB6 100%);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
}
}
}
</style>