Alternative to this.$children in vue in vue 2 I can to this
<tabs>
<tab name="some-title"></tab>
<tab name="some-other-title"> </tab>
</tabs>
and on the tabs componenet I can access all children component with this.$children
created () {
this.tabs = this.$children
},
With this I could create a tab component but now in Vue 3, this.$children is no longer supported and refs is not recommended in the docs.
You know a way to make this work? Thanks.
@vincent15000 I have tried using refs and I can only get hold of children that are insided the component where it is created. e.g.
//inside the tabs.vue component
<template>
<tab ref="tab"></tab>
<tab ref="tab"></tab>
</template>
In the code above, vue refs will return the two tab children but when I use this component elsewhere like
<tabs>
<tab ref="tab">Tab One content</tab>
<tab ref="tab">Tab One content</tab>
</tabs>
In this second example, vue refs will return undefined.
Please sign in or create an account to participate in this conversation.