I recently started working with Vue and am facing an issue with Vue slots
. The component structure is as follows:
<template>
<div class="dropDown__container">
<div
v-show="isOpened"
class="dropDown__content"
style="display:none;"
>
<slot />
<div class="dropDown__container-flex">
<span
class="dropDown__button"
@click="hideDropDown()"
>
Clear
</span>
<span
class="dropDown__button"
@click="hideDropDown(true)"
>
Submit
</span>
</div>
</div>
</div>
There is a method called hideDropdown
within the component that I want to pass to the slot
. Here is how I am using the slot
:
<drop-down>
<div class="d-flex flex-row justify-content-between">
<ul id="priceFromList" class="hintList hintList--left">
<li class="hintList__item" v-for="price in lessThan(autocompletePricesDesktop, editableCriteria.Price.To)" @click="">
{{ price }}
</li>
</ul>
</div>
</drop-down>
I want to be able to pass the hideDropdown
method from the component to the slot
and use it within the @click
event for each li
element. Is this achievable? Any assistance would be greatly appreciated. Thank you.