我用v验证验证。但我不希望它在禁用时验证,我不想让单选按钮在我选择的字段被禁用时验证。我该怎么做?
<v-col cols="6" v-if="Type =='İhracat '">
<v-col cols="12" >
<v-text-field
v-model="customer.Company"
outlined
dense
label="Unvan"
name="Company"
:disabled="radios == 'personal' "
v-validate="'required'"
hide-details="auto"
:error="errors.has('Company')"
:error-messages="$t(errors.first('Company')?'Unvan Boş Geçilemez':'')"
></v-text-field>
</v-col>
<v-col cols="6" v-if="Type =='İhracat '">
<v-text-field
v-model="customer.LastName"
label="Soyad"
name="LastName"
v-validate="'required'"
:disabled="radios == 'institution'"
hide-details="auto"
:error="errors.has('LastName')"
:error-messages="$t(errors.first('LastName')?'Soyad Boş Geçilemez':'')"
outlined
dense
></v-text-field>
</v-col>发布于 2021-03-08 07:21:04
您可以通过检查收音机是否有所需的值来计算值。
Html
:v-validate="validation"计算部分
validation () {
return {
required: this.radios == 'institution'
};
}发布于 2021-03-08 07:55:11
似乎您正在使用vuetify,它已经集成了验证功能。
您可以使用道具“规则”并提供如下的验证
<v-text-field
v-model="customer.Company"
outlined
dense
label="Unvan"
name="Company"
:rules="[v => !!v || 'Field required']"
:disabled="radios == 'personal' "
hide-details="auto" />规则道具采用一个函数数组,布尔或字符串,它需要返回true / false或消息,我建议您将规则设置为常量,以便能够重用它。现在,当禁用文本字段时,可以将条件设置为“不验证”。
const rules = [v => !!v || (!v && radios == 'personal') || 'Field required']有关更多信息,请访问https://vuetifyjs.com/en/api/v-text-field/#props查看道具信息和示例。
https://stackoverflow.com/questions/66525225
复制相似问题