dataV写一个轮播表
时间: 2024-03-02 19:49:55 浏览: 70
以下是一个简单的 dataV 轮播表的代码示例:
```html
<template>
<div class="carousel-table">
<el-carousel :interval="5000" arrow="never" :autoplay="true">
<el-carousel-item v-for="item in tableData" :key="item.date">
<el-table :data="item.data" :header-cell-style="headerCellStyle">
<el-table-column v-for="(column, index) in columns" :key="index" :prop="column.prop" :label="column.label" :min-width="column.width">
<template slot-scope="scope">
{{ scope.row[column.prop] }}
</template>
</el-table-column>
</el-table>
</el-carousel-item>
</el-carousel>
</div>
</template>
<script>
export default {
data() {
return {
tableData: [
{
date: '2022-01-01',
data: [
{ name: 'John', age: 18, address: 'New York' },
{ name: 'Tom', age: 20, address: 'London' },
{ name: 'Lucy', age: 22, address: 'Paris' }
]
},
{
date: '2022-01-02',
data: [
{ name: 'Mike', age: 25, address: 'Tokyo' },
{ name: 'Jane', age: 30, address: 'Beijing' },
{ name: 'Lily', age: 28, address: 'Shanghai' }
]
},
{
date: '2022-01-03',
data: [
{ name: 'Bob', age: 35, address: 'Sydney' },
{ name: 'Jack', age: 40, address: 'Melbourne' },
{ name: 'Marry', age: 36, address: 'Perth' }
]
}
],
columns: [
{ label: 'Name', prop: 'name', width: '120px' },
{ label: 'Age', prop: 'age', width: '80px' },
{ label: 'Address', prop: 'address' }
],
headerCellStyle: {
'background-color': '#f5f7fa',
'text-align': 'center'
}
}
}
}
</script>
<style>
.carousel-table {
width: 600px;
margin: 0 auto;
}
</style>
```
代码中使用了 `el-carousel` 和 `el-carousel-item` 来实现轮播效果,`el-table` 渲染表格数据,利用 `v-for` 指令循环渲染每个时间点的表格数据,最后使用 `:header-cell-style` 属性来设置表头样式,实现表头居中效果。
阅读全文
相关推荐
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)