在表单数据中需要先使用a选择是否启用b 来决定是否显示b输入框,使用v-if判断
<a-row>
<a-col :span="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" class="visitUnit">
是否启用: <a-switch v-decorator"['a', validatorRues.a]" />
</a-form-item>
</a-col>
<a-col :span="24" v-if="this.form.getFieldVale('a')">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol1" style="padding-left: 25%;">
<a-input-number v-decorator"['b', validatorRues.b]" />
</a-form-item>
</a-col>
</a-row>
但是如果form有初始值时,页面回显无法显示b的初始值
可以设置model或者使用现有的data对象来接收a的初始值并为a-switch设置方法
<a-row>
<a-col :span="24">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol" class="visitUnit">
是否启用: <a-switch v-decorator="['', validatorRues.a]" @click="onClick"/>
</a-form-item>
</a-col>
<a-col :span="24" v-if="this.model.a">
<a-form-item :labelCol="labelCol" :wrapperCol="wrapperCol1">
<a-input-number v-decorator"['b', validatorRues.b]"/>
</a-form-item>
</a-col>
</a-row>
onClick(checked) {
this.model.weekFlag = checked;
console.log(' this.model.weekFlag', this.model.weekFlag);
}
b数据正常回显