gpt4 book ai didi

html - Vue : select input placeholder option disappears when I add v-model

转载 作者:行者123 更新时间:2023-12-04 09:02:46 24 4
gpt4 key购买 nike

<select
class="cursoruser-pointer p-2 w-full rounded-full ">
<option class="rounded-full "
disabled selected value="">Language to learn</option>
<option class="rounded-full">German</option>
<option>Spanish</option>
<option>English</option>
</select>
节目
enter image description here
但是,如果我添加 v-model = "selectedLanguage" :
<select v-model = "selectedLanguage"
class="cursoruser-pointer p-2 w-full rounded-full ">
<option class="rounded-full "
disabled selected value="">Language to learn</option>
<option class="rounded-full">German</option>
<option>Spanish</option>
<option>English</option>
</select>
它停止显示占位符:
enter image description here
<script>
...

export default {
...
data: () => ({
selectedLanguage: 'Language to Learn',
}),
...
我如何解决它?

最佳答案

您的初始 selectedLanguage值应为 "" (空字符串),因为您将“Language to learn”选项的值指定为空字符串( value="" )。除此之外,selected不再需要,因为您已经在使用 v-model演示:https://codesandbox.io/s/still-dawn-nu4m8?file=/src/App.vue

关于html - Vue : select input placeholder option disappears when I add v-model,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63528965/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com