How to write custom form component in Ant Design Vue 2x?

534 Views Asked by At

Ant Design Vue v1 provided a documented example for writing custom form components.

The same approach does not apply to version 2x.

How can a custom form component be implemented in AntDV 2x (vue 3) using useForm?

1

There are 1 best solutions below

0
On BEST ANSWER

I believe I have figured this out. Previously your custom component needed to emit a change event:

methods: {
    handleChange(value) {
        this.emit('change', value);
    },
},

Having looked through the source code I learned that you also need to emit an update:value event as well:

methods: {
    handleChange(value) {
        this.emit('update:value', value);
        this.emit('change', value);
    },
},