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: "" }],