欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue2.0 下拉框默認(rèn)標(biāo)題設(shè)置方法

 更新時(shí)間:2018年08月22日 08:45:02   作者:vae的粉  
今天小編就為大家分享一篇vue2.0 下拉框默認(rèn)標(biāo)題設(shè)置方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧

昨天到今天,用vue2.0在寫一個(gè)性別選擇框,一給option添加seledted屬性就報(bào)錯(cuò)這里

下面是報(bào)錯(cuò)的代碼

ERROR in ./~/vue-loader/lib/template-compiler.js?id=data-v-c231dfa2!./~/vue-loader/lib/selector.js?type=template&index=0!./src/components/second.vue
template syntax error <select v-model="selected">:
inline selected attributes on <option> will be ignored when using v-model. Declare initial values in the component's data option instead.

selected 已經(jīng)綁定在<select></select> 上了 , 你選擇了哪個(gè)選項(xiàng), selected 就是那個(gè)選項(xiàng)的value了 ,你想讓哪個(gè)選項(xiàng)為默認(rèn)選中的話,就在data里的seleced 設(shè)置為那個(gè)選項(xiàng)的value

在單擊<select></select> 時(shí),給'性別'這個(gè)選項(xiàng)添加一個(gè)disabled屬性就可以禁用了

<template>
 <select v-model='selected' @click="ss()">
 <option v-for="(option,index) in options" v-bind:value="option.value" :disabled="option.disabled">
 {{ option.text }}{{index}}{{option.disabled}}
 </option>
 </select>
 <span>Selected: {{ selected }}</span>
</template>
<script>
 export default{
 name: 'second',
 data(){
 return {
 selected: 'sex', // 比如想要默認(rèn)選中為性別,那么就把他的value值設(shè)置為'sex'
 options: [
 {text: '性別', value: 'sex', disabled: ''}, //每個(gè)選項(xiàng)里面就不用在多一個(gè)selected 了
 {text: '男', value: '1'},
 {text: '女', value: '2'}
 ]
 }
 },
 methods: {
 ss: function () {
 this.options[0].disabled = disabled;
 },
 }
 }
</script>

以上這篇vue2.0 下拉框默認(rèn)標(biāo)題設(shè)置方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評(píng)論