Closed
Description
Version
3.2.29
Reproduction link
Steps to reproduce
Create a template with <select v-model="...">
and some <option :value="...">
elements. And then look at the rendered HTML. There will never be a selected
attribute on the option
elements.
When loading the SSR rendered page with disabled JavaScript it will always select the first option, because no option
in the HTML is actually selected
.
What is expected?
Similar behavior to <input v-model="...">
. For input
elements this will insert a value="..."
attribute.
Though <select v-model="...">
should insert a selected
attribute for the selected option element. (Or elements when using <select multiple>
).
What is actually happening?
No selected
attribute is added to the SSR rendered HTML.
A workaround is to set :selected
manually:
<select v-model="selected">
<option disabled value="">Please select one</option>
<option value="A" :selected="selected === 'A'">A</option>
<option value="B" :selected="selected === 'B'">B</option>
<option value="C" :selected="selected === 'C'">C</option>
</select>