【问题标题】:How to set a default value in <v-select>?如何在 <v-select> 中设置默认值?
【发布时间】:2020-07-22 10:34:57
【问题描述】:

我在这里有这个选择:

<v-select px-4 class='select'
      v-model="form.accountType"
      :items="accountTypes"
      :label="$t('form.accountType')"
      :rules="[rules.required, rules.validAccountType]"
      color= 'primary'
      ></v-select>

我想要选择的初始选择项之一:

accountTypes () {
  const types = [
    {
      value: 'business',
      text: this.$t('form.accountTypeBusiness')
    },
    {
      value: 'personal',
      text: this.$t('form.accountTypePersonal')
    }
  ]
  return types
}

我已经通过了这个道具:

form: {
    accountType: 'Personal'
}

但是v-model 不起作用。有没有办法将Personal设置为默认值?

【问题讨论】:

    标签: vue.js vuetify.js


    【解决方案1】:

    值区分大小写,因此以小写字母开头,因为数组中的值以小写字母开头。

    form: {
       accountType: 'personal'
       // -----------^--------
    }
    

    【讨论】:

      猜你喜欢
      • 2021-05-25
      • 2017-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-25
      • 1970-01-01
      • 1970-01-01
      • 2019-07-15
      相关资源
      最近更新 更多