el-table代码如下:
<el-table
border
:data="tableinfo.data"
width="100%"
height="100%"
:fit="true"
ref="tableRef"
:header-cell-style="{ 'text-align': 'center' }"
:cell-style="{ 'text-align': 'center' }"
@row-click="clickTable"
row-key="ID"
>
<el-table-column type="index" width="50" label="序号" />
<el-table-column prop="FieldName" label="字段名" />
<el-table-column prop="Showlabel" label="显示名" />
<el-table-column prop="Seq" label="排序" width="100">
<template #default="scope">
<el-input
@click.stop=""
v-model="scope.row.Seq"
type="text"
clearable
></el-input>
</template>
</el-table-column>
<el-table-column prop="IsshowInTalbe" label="显示" width="100">
<template #default="scope">
<el-switch
@click.stop=""
inline-prompt
v-model="scope.row.IsshowInTalbe"
active-text="是"
inactive-text="否"
/>
</template>
</el-table-column>
<el-table-column type="expand" width="1" class-name="detailShow">
<template #default="props">
<ul class="expand-form">
<li>
<span class="title">显示名:</span>
<span class="content">
<el-input
@click.stop=""
v-model="props.row.Showlabel"
type="text"
clearable
></el-input>
</span>
</li>
</ul>
</template>
</el-table-column>
</el-table>
展开列加:class-name="detailShow";
方法如下:
const tableRef = ref<InstanceType<typeof ElTable>>(); //表标识
const clickTable = (row, index, e) => {
tableRef.value.toggleRowExpansion(row);
};
toggleRowExpansion(row)这样写无需用true和false,单击展开与闭合;
样式如下:
/deep/.detailShow {
display: none;
}
注意:加/deep/,不然无效;