主要是選擇值問(wèn)題
上代碼:
<el-select v-model="selectCountry" placeholder="請(qǐng)選擇" @change="selectValue()">
<el-option
v-for="item in countryData"
:key="item.abbreviation"
:label="item.country"
:value="item.country">
</el-option>
</el-select>
1.通過(guò)el-select的change事件會(huì)在選中值變化時(shí)觸發(fā),而選擇的值存放在 v-model="selectCountry"中
2.在methods中,change的綁定事件進(jìn)行獲取
selectValue() {
console.log(this.selectCountry)//打印輸出的是 :value="item.country"的值
},
3.這是我的數(shù)據(jù)
countryData:[
{"country":"Afghanistan","abbreviation":"AFG"},
{"country":"Albania","abbreviation":"ALB"},
{"country":"Algeria","abbreviation":"DZA"},
{"country":"All Qatar","abbreviation":"QAT"},
{"country":"angola","abbreviation":"AGO"},
]