效果图:
HTML部分:
<el-collapse v-model="activeNames"
style="border:none;margin-left:30px;">
<el-collapse-item name="1">
<template slot="title">
<p class="title">运行信息</p>
</template>
<div class="row"
style="margin-top:18px;">
<span>开关:{{on}}</span>
<span style="margin-left:77px">亮度:{{light}}</span>
</div>
</el-collapse-item>
<el-collapse-item name="2">
<template slot="title">
<p class="title">设备信息</p>
</template>
<div class="row"
style="margin-top:18px;">
<p class="col_left">设备名称:{{devName}}</p>
<p class="col_right">产品名称:{{prodName}}</p>
</div>
<div class="row"
style="overflow:hidden">
<p class="col_left">设备ID:{{devId}}</p>
<p class="col_right">规格型号:{{modelId}}</p>
</div>
</el-collapse-item>
</el-collapse>
script部分:
<script>
export default {
data () {
return {
on: "开",
light: 100,
devName: '虎牌双色灯',
prodName: '双色灯',
devId: 'M000012',
modelId: '双色灯5045',
activeNames: ['1', '2']
//这里的activeNames要与<el-collapse>绑定的v-model值一致
//['1', '2']里面的值要与<el-collapse-item>唯一表示name属性值一致
//这样就可以实现默认展开指定折叠面板块
}
}
}
</script>
css部分:
<style>
.title {
font-size: 18px;
font-family: Microsoft YaHei;
font-weight: bold;
color: #303133;
padding-bottom: 17px;
padding-top: 17px;
}
::v-deep .el-collapse-item__header.is-active {
border-bottom: 1px solid #ebeef5;
}
::v-deep .el-collapse-item__wrap {
border: none;
}
p {
margin: 0;
padding: 0;
}
.row {
overflow: hidden;
margin-bottom: 22px;
}
.row .col_left {
float: left;
width: 420px;
}
.row .col_right {
float: left;
}
</style>