Failing to get initial value (Vue 3)
See original GitHub issueThis is my code. It works just fine, except when “restaurantId” has initial value, it doesn’t pre-select the option.
<restaurant-autocomplete v-model="filters.restaurantId" />
//Int
RestaurantAutocomplete.vue:
<template>
<Multiselect
:delay="500"
:resolveOnLoad="!!$attrs.modelValue"
:options="async (q) => await autocomplete(q)" // [{value: Int, label: String}]
:searchable="true"
:filterResults="false"
:clearOnSearch="true"
:clearOnSelect="false"
placeholder="Restaurant"
:loading="loading"
@select="$emit('update:modelValue', $event)"/>
</template>
Issue Analytics
- State:
- Created 3 years ago
- Comments:8
Top Results From Across the Web
VueJS 3 - V-model not updating the initial data value
The v-model in not making the data reactive. I'm using vue@3.2.31 with Chromium browser version 88 on Linux and I have the following...
Read more >Options: State - Vue.js
A function that returns the initial reactive state for the component instance. ... default : Specifies a default value for the prop when...
Read more >Initial inline input value · Issue #3924 · vuejs/vue - GitHub
I took a look at the migration guide and found a confirmation it was not possible anymore, but I can't find any workaround....
Read more >How to set a default value to input with a v-model via HTML?
As i said in the post, vue ignores default value when using v-model, is not possible change it dynamically too, we get this...
Read more >Vue 3 Composition API: How to Omit `.value` in refs
In situations where we have a function that returns a ref , the Vue compiler would not be able to know that the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
But can you actually see Multiselect’s
modelValue
prop being set? I don’t think so because attribute inheritance works with non-prop attributes and:modelValue
is a prop. So adding:modelValue="modelValue"
to multiselect should solve the problem.Btw generally if you have
resolveOnLoad
set totrue
and the resulting async option list contains an item whichvalue
equals to the initially setmodelValue
it will be selected once the async process finishes.I used
:model-value="default_value"
that’s worked for me in Vue 3