el-table动态表单
//关键代码
//{{ scope.row['select' + index] }}
//vue v-model拼接
//v-model="radioSelect['radio'+index]"
//radioSelect:{
// radio0:'',
// radio1:'',
// radio2:''
//},
<el-table-column
v-for="(v, index) in tableHerds"
:key="`tableHerdsGd_${index}`"
align="center"
:label="v.name"
:min-width="`70px`"
>
<!-- 非空验证显示星号 -->
<!-- <template slot="header">
<span v-if="v.isRequired === '1'" class="asterisk">*</span>
<span>{{ v.columnName }}</span>
</template> -->
<template slot-scope="scope">
<div class="nameDiv" v-if="v.type === 'checkbox'">
<el-checkbox
v-model="scope.row['checkbox' + index]"
:disabled="true"
></el-checkbox>
</div>
<div v-else>
{{ scope.row['select' + index] }}
</div>
</template>
</el-table-column>
<el-table-column
prop="address"
label="操作"
align="center"
min-width="100"
>
<template slot-scope="scope">
<el-button
@click="handleClick(scope.row, '1')"
type="text"
size="small"
>人员详情</el-button
>
</template>
</el-table-column>
附加记录:解决el-table添加fiexd属性出现的表格错位问题
学习记录:
通过 doLayout 方法解决
1、数据更新后出现的错位问题
1.1 直接在数据赋值后执行doLayout方法
this.data = data;
// 在数据更新后执行
this.$nextTick(() => {
// myTable是表格的ref属性值
if (this.$refs.myTable && this.$refs.myTable.doLayout) {
this.$refs.myTable.doLayout();
}
})
1.1 直接在数据赋值后执行doLayout方法
this.data = data;
// 在数据更新后执行
this.$nextTick(() => {
// myTable是表格的ref属性值
if (this.$refs.myTable && this.$refs.myTable.doLayout) {
this.$refs.myTable.doLayout();
}
})
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 提示词工程——AI应用必不可少的技术
· 字符编码:从基础到乱码解决
· 地球OL攻略 —— 某应届生求职总结