D
D
daniel_wesson2022-01-12 15:16:12
Vue.js
daniel_wesson, 2022-01-12 15:16:12

VueJS: How to get all child components in parent?

There are 3 conditional

App.vue components

<template>
  <v-custom>
    <v-custom-action>world</v-custom-action>
    <p>Hello</p>
  </v-custom>
</template>

custom.vue
<template>
  <div>
    <slot />
  </div>
</template>

<script>
Какая-то логика
</script>

CustomAction.vue
<template>
  <div>
    <slot />
  </div>
</template>


The problem is that the Custom component needs to know if the CustomAction is present, if it is present, then get access to its DOM element (well, or to its context). Maybe this can ideally be solved without using the 3rd component (CustomAction).
PS in vue 2 there is this.$children and it seems to solve the problem, but in vue 3 it was cut out for some reason

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander, 2022-01-12
@Aleksandr-JS-Developer

this.$children and that seems to solve the problem, but it was cut in vue 3 for some reason

What you are doing is the wildest anti-pattern. Therefore, they drank it.
Use Vux.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question