Vue parent component acquires child component data object

I want to get the row child component data object on the parent component

<ct-select
    v-model="text"
    @getSearchName="getName">
    <ct-option 
      v-for="(item, index) of dataList" 
      :key="index"
      :value="item.value"
      :label="item.label">
    </ct-option>
  </ct-select>

under mounted in ct-select , use this.$slots.default
to get undefined , because dataList is obtained asynchronously

  //ct-select
  export default {
    mounted() {
        console.log(this.$slots.default) //undefined
    }
  }

is there any way to get data objects on subcomponents in mounted asynchronously?

Supplementary questions
actually I want to do something similar to the elementUi drop-down option

clipboard.png
the reason why I do this is to get the data in the child component on the parent component for page conversion.
because I made such a plug-in without thinking about it before, but found that
is not flexible when giving values, so I want to change it to the same function as elementui , but I read the source code of elementui , but I am a little confused

.
<el-select v-model="value" placeholder="">
    <el-option
      v-for="item in options"
      :key="item.value"
      :label="item.label"
      :value="item.value">
    </el-option>
  </el-select>
Feb.20,2022

when the parent component is rendered, the child components have nothing. How else can you get


you need to get the data after asynchronous success. DataList initialization is arr or obj


in the mounted phase of the parent component, what state is the child component in? it may not be rendered yet. What is your starting point for doing this? to put it simply, there may be other better solutions?

< hr >

updated

well, according to your update to the problem, as I understand it, you want to get the vm of the child component within the parent component, right? for example, the parent component has an options attribute whose value is an array formed by the option attribute of all child components or directly the child component vm itself, right?

if so, I can tell you how element-ui is implemented. The principle is very simple: the parent component is injected into the child component through inject, and then the child component is registered through the reference property of the parent component. The official source code is here .

the code about the parent component providing dependencies is in here , and the logic of child component injection is in here . About provider/inject itself, you can take a look at the official documentation, or take a look at my previous article, Advanced Vue component pattern .

this implementation is logically opposite to the one described in your question. This is reasonable because the parent component cannot know the rendering status of the child component in advance (as in the case of undefined here), so the parent component's description of the child component needs to be initialized by the child component, so inject the parent component into the child component as a dependency, and then carry out the relevant initialization logic.

this pattern is widely used when implementing components that have a parent-child many-to-one relationship, such as tabs, form, and so on.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e54358-4420c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e54358-4420c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?