Vue imitates ele.me drop-down box, how to bind the value in slot

want to get the value of cusOptions.vue on the cusSelect.vue page

/* cusSelect.vue */
<template>
  <div>
    <input type="text" v-model="value">
    <ul class="select-list" v-show="isopen">
      <slot @get-value="handleSelect"></slot>
    </ul>
  </div>
</template>

<script>
  methods: {
    // value
    handleSelect (value) {
      this.value = value
    }
  }
</script>
/* cusOptions.vue */
<template>
  <li @click.stop="handleSelect">{{label}}</li>
</template>

<script>
  props: {
    value: String,
    label: String
  },
  methods: {
    handleSelect () {
      this.$emit("getValue", this.value)
    }
  }
</script>
/* pageA */
<cus-select :list="list">
  <cus-option
    v-for="item in warehouseGroup"
    :key="item.value"
    :label="item.label"
    :value="item.value">
  </cus-option>
</cus-select>
Mar.04,2021

just looked at the implementation of each component library.
is usually bound in the created phase of select

created () {
  this.$on('setSelected', this.handleSelect)
}

use a custom dispatch in options to trigger this event

this.dispatch('', 'setSelected', '')

dispatch traverses the parent of the child component until it finds parent.name = 'parent component name' and then triggers it with $emit.

this is the dispatch code of element-ui


write down the drop-down box yourself or write it in JSX. Many of the things you need are in the object $vnode.data

.
Menu