vue+element-ui el-table组件内表单验证问题
添加rules
rules: {
variable_name: [{ required: true, message: '名称不能为空', trigger: "blur" }]
}
复制代码
html代码
<el-form ref="variableForm" :model="variable">
<el-table :data="variable.Variable">
<el-table-column label="名称">
<template slot-scope="scope">
<el-form-item :prop="'Variable.' + scope.$index + '.Name'" :rules='rules.variable_name'>
<el-input v-model.trim="scope.row.Name"></el-input>
</el-form-item>
</template>
</el-table-column>
</el-table>
<el-form>
复制代码
js代码
this.$refs.variableForm.validate(variable => {
if (!variable) {
return;
}
}
复制代码
关键:
如何给el-form-item动态绑定prop
:prop="'Variable.' + scope.$index + '.字段名'"
所有评论(0)