pmpc
pmpc

Reputation: 493

How to extend a component in Vue 3?

The import is working just fine in case I try to use the component from element-plus directly.

What I'm trying to do though, is to extend a component from element-plus library (it uses the composition api from Vue 3) and add some additional properties to my component and methods.

In Vue 2 it would look something like this:

export default {
  extends: SomeComponent
}

In Vue 3 this seems to not be working anymore.

I've read about defineComponent but so far, without success implementing it.

Can someone shed me some lights? Thanks.

Upvotes: 4

Views: 7459

Answers (1)

pmpc
pmpc

Reputation: 493

In order to extend a component that uses Composition API whereas another still uses Options API, we need to also do the setup, such as:

export default { extends: SomeComponent, setup: SomeComponent.setup }

Upvotes: 7

Related Questions