别忘了给el-form-item设置prop值
下面代码的required不能加,因为这一项绑定的值不在formData,加了虽然会有红色号,但是验证会遇到麻烦,去除,自定义样式,给item加一个class=“red-star",然后设置label的:before样式
<el-form :inline="true" :model="formData"
:show-message="false"
:rules="rules">
<el-form-item label=" 一级名称" required prop="pl1Name">
<el-input v-model="treeNodeData.data.label"></el-input>
</el-form-item>
......
rules: {
pl1Name: [
{
validator: (rule, value, callback) => {
valid.notNull(rule, value, callback, this.treeNodeData.data.label)
},
trigger: 'blur'
}
],
pl1NameEn: [
{ validator: valid.notNull, trigger: 'blur' }
],
pl1Weight: [
{
validator: (rule, value, callback) => {
valid.notNull(rule, value, callback, this.treeNodeData.data.precent)
},
trigger: 'blur'
}
]
}
}
网友评论