赞
踩
父组件
<radio-item ref="child" />
<el-button type="primary" @click="handleClick">确定</el-button>
handleClick() {
let flag = this.$refs['child'].validateForm();
console.log(11111111111, flag);
},
子组件
<el-form ref="formline" :model="formline" :rules="rules">
<div style="width: 450px;">
<div v-for="(item, index) in formline.lists" :key="index">
<el-form-item
:label="'选项'+ letter(index)"
:rules="[{required: true, message: '请输入', trigger: 'blur'}]"
:prop="'lists.' + index +'.name'"
>
<el-input v-model="item.name" clearable />
</el-form-item>
</div>
<el-button type="primary">添加</el-button>
</div>
</el-form>
validateForm() {
let flag = null;
this.$refs['formline'].validate((valid) => {
if (valid) {
flag = true
} else {
flag = false
return false
}
})
return flag
},
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。