iview Form验证自定义组件

this.$parent.$emit("on-form-change");

 

 

freeCom.vue

<input type="text" name="" id="" @input="emitfun" v-model="val" />

emitfun() { 
this.$parent.$emit("on-form-change");
this.$emit("input", this.val)
}

 

 

hello.vue

<Form ref="formValidate" :model="formValidate" :label-width="80">
<FormItem label="Name" prop="name" :rules="validate">
<freeCom @abcdefg="abcccc" v-model="formValidate.name" ></freeCom>
</FormItem>

<FormItem>
<Button type="primary" @click="handleSubmit('formValidate')">Submit</Button>
<Button @click="handleReset('formValidate')" style="margin-left: 8px">Reset</Button>
</FormItem>
</Form>

 

 

**************************elementUI*未验证是否可用************************************


this.$parent.$emit("el.form.change");

this.$parent.$emit("el.form.blur");

posted @ 2021-11-05 16:02  mrt_yy  阅读(427)  评论(0编辑  收藏  举报