vue3 数据可视化大屏 开发中,需要展示一些表格效果,今天整理滚动表格效果。
通过使用flex控制宽度,通过Vue3SeamlessScroll实现列表滚动.
演示地址
使用组件
<template>
<div class="itemBodys2">
<iTable></iTable>
</div>
</template>
<script>
import iTable from './iTable.vue'
export default {
name: "title",
data() {
return {
}
},
components: {iTable},
props: {
title: {
type: String,
default() {
return '';
}
}
},
watch: {},
mounted() {
var that = this;
},
}
</script>
<style lang="scss" scoped>
.itemBodys2 {
position: relative;
width: 100%;
height: calc(100% - 20px);
margin-top: 20px;
}
</style>
组件代码
<template>
<div class="tableCom">
<div class="tableHead">
<div class="tableHeadItem" v-for="(item,index) in head" :key="index" :style="{flex:item.flex}">{{ item.title }}
</div>
</div>
<Vue3SeamlessScroll :step="0.5" :wheel="true" :hover="true" :list="list" class="tableBody">
<div class="tableBody2" v-for="(item,index) in list" :key="index">
<div class="tableBody2Item" :style="{flex: head[0].flex}">
00{{ index }}
</div>
<div class="tableBody2Item" :style="{flex: head[1].flex}">
<span class="num">人事系统</span>
</div>
<div class="tableBody2Item" :style="{flex: head[2].flex}">
<span class="num">23:00 / 07:26 / 17:30</span>
</div>
<div class="tableBody2Item" :style="{flex: head[3].flex}">
<div class="zc" v-if="item.type">正常</div>
<div class="yc" v-else>异常</div>
</div>
</div>
</Vue3SeamlessScroll>
</div>
</template>
<script>
import {Vue3SeamlessScroll} from "vue3-seamless-scroll";
export default {
name: "tableCom",
components: {Vue3SeamlessScroll},
props: {
head: {
type: Array,
default() {
return [{
title: '序号',
flex: 0.5
}, {
title: '系统名称',
flex: 1
}, {
title: '集成时间',
flex: 1.5
}, {
title: '当前状态',
flex: 0.8
}];
}
},
},
data() {
return {
list: [{
type: 0
}, {
type: 1
}, {
type: 0
}, {
type: 1
}, {
type: 0
}, {
type: 0
}, {
type: 0
}, {
type: 0
}, {
type: 0
},]
}
},
watch: {},
mounted() {
},
methods: {}
}
</script>
<style lang="scss" scoped>
.tableCom {
width: calc(100% - 0px);
margin-left: 0px;
position: relative;
height: 100%;
overflow: hidden;
.tableHead {
width: 100%;
height: 39px;
background: rgba(48, 142, 255, 0.3);
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
.tableHeadItem {
font-size: 14px;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #55E3FF;
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
padding-left: 15px;
flex: 1;
}
}
.tableBody {
position: relative;
height: calc(100% - 34px);
overflow: hidden;
.tableBody2 {
min-height: 34px;
padding-top: 5px;
padding-bottom: 5px;
background: rgba(#308EFF, 0);
display: flex;
justify-content: center;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
.tableBody2Item {
font-size: 14px;
font-family: MicrosoftYaHei;
font-weight: 400;
color: #CAD3ED;
text-shadow: 0px 4px 10px rgba(0, 42, 108, 0.12);
display: flex;
justify-content: flex-start;
align-items: center;
flex-wrap: nowrap;
flex-direction: row;
padding-left: 15px;
flex: 1;
.num {
width: calc(100% - 15px);
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
}
}
.tableBody2:nth-child(2n) {
background: rgba(48, 142, 255, 0.24);
}
}
.status {
color: rgba(13, 206, 242, 1);
}
}
.zc {
font-size: 14px;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #46FFBE;
}
.yc {
font-size: 14px;
font-family: PingFang SC-Bold, PingFang SC;
font-weight: bold;
color: #FF5B5B;
}
</style>
项目应用
vue3 滚动表格效果 在数据可视化大屏项目中的使用实例