ant design vue 使用a-select设置默认值

2022-01-22  本文已影响0人  CoderZb

a-select中使用v-model即可。

\color{#FF00FF}{效果如下:}

image.png

\color{#FF00FF}{全部代码如下:}

<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>

上一篇 下一篇

猜你喜欢

热点阅读