Select的使用
<span style="margin-right: 10px;line-height: 32px;">專業</span>
<Select v-model="form.major" filterable style="width:150px;margin-right: 15px;" placeholder="選擇專業">
<Option style="width:130px;" v-for="(item,index) in majorList" :value="item.value" :key="index">
{{item.label}}
</Option>
</Select>
data() {
return {
form: {
major: '',
},
majorList: [],
}
},
mounted() {
this._getSelectList();
},
methods: {
_getSelectList() {
this.$api.picInterface.listeMajor().then(res => {
res = res.data;
if (res.success) {
this.majorList = (() => {
let arr = [];
[...res.data.majorList].map(m => arr.push({value: m.majorId, label: m.majorName}));
return arr;
})();
} else {
this.$Message.error(res.retMsg);
}
}).catch(err => console.error(err))
},
}
複製程式碼