I am creating a dropdown menu in v-select
and after selecting an option when clicking the clear button, I need to clear the dropdown menu and change the options array to the initial stage.
How to check if clear button(x) is clicked, I tried using on-change
for getting the selected value and it works fine while @click
etc. don't It works, please help me.
<template> <v-select v-model="selected" :reduce="(option) => option.id" :options="[ { label: 'One', id: 1 }, { label: 'Two', id: 2 }, ]" @onChange="searchProduct" /> </template> <script> export default { data() { return { selected: 3, } }, methods(){ searchProduct(selected){ console.log('selected value ',selected) } } </script>
I was expecting some way to handle the dropdown clear event.
Since we don't have any explicit
events
yet, we can achieve this requirement by observing thev-model
value.Live demonstration upon request :