ant design vue 使用a-select设置默认值
2022-01-22 本文已影响0人
CoderZb
在
a-select
中使用v-model
即可。
<template>
<div>
<a-select v-model="cardAttr" placeholder='请选择账户类型' style='width: 230px' @change='handleAccountTypeChange'>
<a-select-option :value='item.id' v-for="(item,index) in cardType" :key='index'>
{{item.name}}
</a-select-option>
</a-select>
</div>
</template>
<script>
export default {
data() {
return {
cardType:[{'id':"1",name:'私人账户'},{'id':"2",name:'公司账户'}],
cardAttr:null,
};
},
methods:{
handleAccountTypeChange(e){
console.log('账户类型',e);
this.cardAttr = e;
},
},
mounted() {
this.cardAttr = '2';
}
};
</script>
<style>
</style>