Iview assigns an asynchronous value to the data bound to the select component, how to avoid triggering rules verification of Form?

topic description

using the select component of iview, the data in the component needs to be obtained asynchronously. After obtaining the assignment, rules verification in Form is triggered, resulting in an error message as soon as the page is opened

sources of topics and their own ideas

using created to get the data and return the assignment, removing the trigger: "change", in rules will still trigger the verification of rules, with an error prompt

rulestriggerblurblurrules

.

related codes

select components

<FormItem label="" prop="fundsCategory">
    <Select v-model="formValidate.fundsCategory">
        <Option v-for="item in initData.fundsCategory" :value="item.value" :key="item.value" :label="item.label"></Option>
    </Select>
</FormItem>

Form components

<Form ref="projectAddForm" :model="formValidate" :rules="ruleValidate" :label-width="180">

get select data asynchronously

this.initData.fundsCategory = (await Ajax.get("/api/xxxxxxxxx")).data.result.map((item:any) => {
    return {
        label: item.displayName,
        value: item.id
    }
})
rules in rules validation
fundsCategory: [{ required: true, type: "number", message: "" }], 

how can you avoid triggering rules validation when assigning values asynchronously? Or how to get iview to validate rules after all asynchronous requests come back? Please give us your advice

Apr.05,2021

has not had this problem since it was upgraded to iview 3.0.0.

Menu