I need my component to get slots number are occupied by the parent component
For example:
This is the component:
<template>
<div>
<slot/>
</div>
</template>
<script>
name: 'comp',
data() {
return {
nslot: 0
}
}
</script>
This is the parent
<template>
<div>
<component>
<button slot=""></button>
<button slot=""></button>
<button slot=""></button>
<button slot=""></button>
...
<component/>
</div>
</template>
<script>
name: 'comp'
</script>
How i can do? I want to get number of used slot in the "nslot" variable
I prefer using method, (in the component) like:
mounthed() {
this.nslot = this.getslotnumber()
}