结合element的rule表单校验,使用await获取promise的reject内容,使用try和catch方法
<el-form-item
label
:prop="'tableDataMidField.' + scope.$index + '.function2'"
:rules="[{ required: true, message: '请输入', trigger: 'blur' }, {validator: validateTables, trigger: 'blur'}]"
>
<el-input v-model="scope.row[v.prop]"></el-input>
</el-form-item>
async validatorCommon(value, callback, params) {
let response = null
try {
response = await parseFunction(params) //this.parseFunction(params)
return callback();
} catch (e) {
return callback(new Error(`${e}`));
}
},
网友评论