VueSeamlessScroll需要先npm安装,引入下面已经写了。修改上部分的标题和你的table数据字段即可。传列表的值给这个组件监听。监听到即可生成。
<template>
<div class="table-box">
<div class="t-head">
<div class="th">标题1</div>
<div class="th">标题2</div>
<div class="th">标题3</div>
<div class="th">标题4</div>
</div>
<div class="t-body">
<VueSeamlessScroll :key="scrollKey" :vScaleY="'100%'" :data="data" :classOption="{ singleHeight: 39}" class="warp">
<ul class="item">
<li v-for="(item, index) in data" :key="index">
<span class="td ell" :title="item.xx1">{{ item.xx1 }}</span>
<span class="td ell" :title="item.xx2">{{ item.xx2 }}</span>
<span class="td ell" :title="item.xx3">{{ item.xx3 }}</span>
<span class="td ell" :title="item.xx4">{{item.xx4}}</span>
<!-- <span class="td">-->
<!-- <span v-if="item.zhuangtai===0" style="color:#28FF97;">状态1</span>-->
<!-- <span v-if="item.zhuangtai===1" style="color:#FFAF31;">状态2</span>-->
<!-- </span>-->
</li>
</ul>
</VueSeamlessScroll>
</div>
</div>
</template>
<script>
import VueSeamlessScroll from 'vue-seamless-scroll'
export default {
name: 'ClosedLoop',
components: {
VueSeamlessScroll
},
props: {
TableData: {
type: Array,
default: () => []
}
},
data() {
return {
scrollKey: 1,
data: [],
compressWidth: false
}
},
watch: {
TableData() {
this.data = this.TableData
this.scrollKey++
}
},
created() {
this.data = this.TableData
},
mounted() {
},
methods: {
}
}
</script>
<style lang='scss' scoped>
.table-box{
padding: 0 15px;
.t-head{
display: flex;
justify-content: space-between;
align-items: center;
padding-bottom: 5px;
padding-top: 10px;
.th{
width: 25%;
font-size: 11px;
font-family: DOUYUFont;
font-weight: 700;
font-style: italic;
color: #00E5ED;
text-align: center;
padding: 0 0;
}
}
.t-body{
height: calc(100% - 40px);
}
.warp{
height: 100%;
margin: 0 auto 0;
overflow: hidden;
ul {
list-style: none;
padding: 0;
margin: 0 auto;
li {
position: relative;
display: flex;
justify-content: space-between;
align-items: center;
font-size: 14px;
cursor: pointer;
height: 28px;
background: transparent;
font-family: Source Han Sans CN;
font-weight: 400;
color: #ffffff;
&:hover{
//background-color: rgba(25, 101, 194, 0.74);
.sanjiao{
display: block;
}
}
}
li:nth-child(2n - 1){
background: rgba(39, 104, 136, 0.3);
}
.td{
display: block;
width: 25%;
padding: 0 8px;
text-align: center;
}
.ell{
white-space:nowrap;//不换行
overflow: hidden;//超出隐藏
text-overflow: ellipsis;//变成...
}
}
}
}
</style>