<el-select v-model="value8" filterable placeholder="請選擇" value-key="id" @change="currentSel"> <el-option v-for="item in options" :key="item.id" :label="item.label" :value="item"></el-option> </el-select>
需要注意的是:value-key="id"
這里的 id 需要和 el-option 的 key 綁定的屬性一致,而且 value 綁定整個整個 item 對象
currentSel(selVal) {
this.code = selVal.code;
this.name = selVal.label;
console.log("選擇的name為:" + this.name, "選擇的code為:" + this.code);
console.log(selVal);
},