1.3.13
Chrome 75
https://vue.ant.design/components/form-cn/#components-form-demo-customized-form-controls
对input做一层简单封装
<template>
<div>
<a-input
v-bind="$attrs"
:value="input"
@change="triggerChange"
/>
</div>
</template>
使用
<a-form-item label="CustomInput">
<CustomInput
v-decorator="[
'CustomInput',
{
rules: [{ required: true, message: '请输入' }]}
]"
/>
</a-form-item>
控制台报warning:
CustomInput
default valuecan not collect, please useoption.initialValueto set default value.
按照提示去设置initialValue,还是有问题
<a-form-item label="CustomInput">
<CustomInput
v-decorator="[
'CustomInput',
{
initialValue:'',//空值也不行,必须不为空才行??
rules: [{ required: true, message: '请输入' }]}
]"
/>
</a-form-item>
希望能像input一样,不需要设置initialValue也正常
props: {
value: {
type: String,
- default: '',
},
},
去除。
这个问题会在之后的版本优化,设置了 default 也不会在提示
这样是可以了,期待优化下~
1.3.13已经优化了的,还有问题? @mkanako
@tangjinzhou
1.3.13是解决了这个issue吧https://github.com/vueComponent/ant-design-vue/issues/915
但我看报的warning不一样,目前确实还是有问题
哦哦 这个是提醒 form 无法收集内部的默认值,如果有默认值,可以使用 initialValue,这样也不会报warning
@tangjinzhou
initialValue:'',//空值也不行,必须不为空才行??
initialValue如果是空字符串照样warning啊
另外我拿我上面的例子来说,我用input封装了个组件出来
我希望这个组件基本行为表现跟input一致
使用者在使用这个组件的时候能像input一样无需设置initialValue也正常
不设置这个事情,目前有点困难 所以加了提醒 😓
还是有问题,a-form-item里嵌套一个自定义组件,当设置
value: {
type: String,
default: ''
},
时报错:initialValue is not defined。
注释掉后不再报错
value: {
// type: String,
// default: ''
},
同上,只能先跳过eslint校验,这样不设置initialValue也不报错

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Most helpful comment
还是有问题,a-form-item里嵌套一个自定义组件,当设置
value: { type: String, default: '' },时报错:initialValue is not defined。
注释掉后不再报错
value: { // type: String, // default: '' },