Sometimes, we want to get $children by component name with Vue.js.
In this article, we’ll look at how to get $children by component name with Vue.js.
How to get $children by component name with Vue.js?
To get $children by component name with Vue.js, we can call find
on this.$root.$children
.
For instance, we write
this.$root.$children.find((child) => {
return child.$options.name === "name";
});
to find the child component with the name
option set to 'name'
.
Conclusion
To get $children by component name with Vue.js, we can call find
on this.$root.$children
.