I have a problem with datalist with my input search in VueJS, why when i click with mouse or with enter on one of the option on my datalist, my function getData() which is called to @click and @keypress.enter is not launched?
here is my code:
template:
<input
list="data"
v-model.trim="searchBy"
@keyup.enter="getAllDatas"
type="text"
placeholder="Find more data..."
/>
<br />
<datalist id="data">
<option v-for="r in repos.items"
:key="r.id"
:value="r.name"
@click="getData(r.id)"
@keypress.enter="getData(r.id)" />
</datalist>
script:
methods: {
getAllDatas() {
fetch(`someURL`)
.then(res => res.json())
.then(
res => {
this.data = res
}
)
},
...mapActions(["fetchData"]),
async getData() {
await this.fetchData();
},
i totally have no idea what is wrong here, can someone tell me?