Combining <datalist>
with <option :value="...">
breaks data selection
#12189
Answered
by
edison1105
spiffytech
asked this question in
Help/Questions
-
I'm trying to use a datalist with Vue, on a component that will rerender while the user is filling out the form. If build my datalist with Am I doing something wrong here? Screencast.from.2024-10-16.10-04-14.mp4<script setup>
import { ref } from 'vue'
const values = ref(['foo', 'bar', 'baz']);
const clock = ref(new Date().toISOString());
setInterval(() => clock.value = new Date().toISOString(), 250)
</script>
<template>
<p>The time is: {{clock}}</p>
<input list="my-datalist" />
<datalist id="my-datalist">
<option v-for="value in values" :value="value">{{value}}</option>
</datalist>
</template> |
Beta Was this translation helpful? Give feedback.
Answered by
edison1105
Oct 16, 2024
Replies: 1 comment 2 replies
-
use v-memo <datalist id="my-datalist" v-memo="[values]">
<option v-for="value in values" :value="value">{{value}}</option>
</datalist> |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
spiffytech
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
use v-memo