提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档
一、vue表格
二、使用步骤
1.正文
代码如下(示例):
<template>
<div class="content">
<el-table
:data="tableData"
border
style="width: 100%">
<el-table-column type="selection" width="55"/>
<el-table-column width="1" class="box">
<template slot-scope="scope">
<div class="item">
<span style="margin-left:-80%">订单编号:{{ scope.row.id }} <span>共<span style="color:#409EFF">10</span>件</span></span>
</div>
</template>
</el-table-column>
<el-table-column label="商品" width="300" class="box">
<template slot-scope="scope">
<div v-for="(item, index) in scope.row.children" :key="index" class="mesSty">
<img class="imgSty" src="https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1607508642445&di=0e36873f5842d9a862bf9f8f2da19510&imgtype=0&src=http%3A%2F%2Fc.hiphotos.baidu.com%2Fzhidao%2Fpic%2Fitem%2Ff3d3572c11dfa9ecc052be8060d0f703918fc12d.jpg" alt="">
<div class="mesFont">
<!-- <p class="pb_sty"><span>{{ item.name }}</span></p> -->
<p>fasdfasfsfs 啊</p>
<p>蓝色:10*5cm</p>
</div>
</div>
</template>
</el-table-column>
<el-table-column min-width="100" label="单价/数量">
<template slot-scope="scope">
<div v-for="(item, index) in scope.row.children" :key="index" class="mesSty2">
<p>{{ item.name }}</p>
<p>X2</p>
</div>
</template>
</el-table-column>
<el-table-column prop="address" min-width="140" label="商品状态">
<template slot-scope="scope">
<div v-for="(item, index) in scope.row.children" :key="index" class="mesSty2">
<p>已导出</p>
</div>
</template>
</el-table-column>
<el-table-column prop="address" min-width="140" label="收货人">
<template slot-scope="scope">
{{ scope.row.address }}
</template>
</el-table-column>
<el-table-column min-width="140" label="订单状态">
<template slot-scope="">
<span>微信</span><span>(100积分)</span>
</template>
</el-table-column>
<el-table-column prop="address" valign="top" min-width="140" label="实收款"/>
<el-table-column
label="操作"
align="center"
min-width="140">
<template slot-scope="scope">
<el-button type="text" size="small" @click="btnClick(scope.row.id)">退款</el-button>
<div>
<el-button type="text" size="small" @click="btnClick(scope.row.id)">订单详情</el-button>
</div>
</template>
</el-table-column>
</el-table>
</div>
</template>
2.data数据及样式
代码如下(示例):
<script>
export default {
data() {
return {
popSty: false,
textarea: '',
tableData: [{
id: 1,
date: '2016-05-02',
name: '王小虎',
address: '12',
children: [
{
name: '撒旦法1'
},
{
name: '撒旦法2'
}
]
}, {
id: 3,
date: '2016-05-01',
name: '王小虎',
address: '12',
children: [
{
name: '撒旦法11'
},
{
name: '撒旦法22'
}
]
}, {
id: 4,
date: '2016-05-03',
name: '王小虎',
address: '12',
children: [
{
name: '撒旦法111'
},
{
name: '撒旦法222'
}
]
}]
}
},
methods: {
btnClick(id) {
console.log(id)
}
}
}
</script>
<style scoped>
.content {
padding: 20px;
}
.el-table--enable-row-transition /deep/ .cell {
padding: 20px 0;
}
.item {
width: 100vw;
background: #f1f1f1;
position: absolute;
top: 0;
left: -55px;
z-index: 1;
height: 50px;
line-height: 50px;
}
</style>
<style scoped>
.imgSty {
width: 100px;
display: block;
padding-left: 10px;
}
.mesSty {
display: flex;
align-items: center;
padding: 40px 0;
border-bottom: 1px solid #ebeef5;
}
.mesSty:last-child {
padding-top: 20px;
border-bottom: none;
padding-bottom: 0px;
}
.mesSty2 {
padding: 40px 0;
border-bottom: 1px solid #ebeef5;
}
.mesSty2:last-child {
padding-top: 20px;
border-bottom: none;
padding-bottom: 0px;
}
.content >>> .el-table--border td:nth-child(-n+4) {
border-right: none!important;
}
.content >>> .el-table--border td:nth-child(2) {
border-left: 1px solid #ebeef5;
}
.content /deep/ .el-table__row td:nth-child(n+6) .cell {
position: absolute!important;
top: 100px!important;
left: 50%;
transform: translateX(-50%);
}
.content /deep/ .el-table__row td:nth-child(1) .cell {
position: absolute!important;
top: -5px!important;
left: 50%;
transform: translateX(-50%);
z-index: 999;
}
.pb_sty span {
background: #1dc8de;
padding: 2px 8px;
border-radius: 4px;
color: #fff;
}
.mesFont p {
margin-block-start: 0;
margin-block-end: 0;
padding: 0 10px;
}
.mesFont p:nth-child(2) {
text-overflow: -o-ellipsis-lastline;
overflow: hidden;
text-overflow: ellipsis;
display: -webkit-box;
-webkit-line-clamp: 2;
line-clamp: 2;
-webkit-box-orient: vertical;
}
/* .el-table__row:hover .item {
background-color: #eaf8ff;
} */
</style>