Quasar框架自动完成功能未在列表中显示文本

时间:2018-10-17 13:10:02

标签: vue.js quasar-framework

我正在使用最新版本的quasar(0.17),并且正在尝试使用自动完成组件。我可以过滤列表并选择一个值,但是自动完成列表中的文本未显示:

enter image description here

这是定义:

<q-field :error="$v.clientInfo.name.$error" error-label="Client name is required">
  <q-input placeholder="Start typing a client's name" float-label="Client Name" type="text" v-model="clientInfo.name" @blur="$v.clientInfo.name.$touch" :before="getIcon('perm_identity')" clearable>

      <q-autocomplete :min-characters="0" :value-field="v => `${ v.name }  (${ v.phone })`" :static-data="{field: 'name', list: clients}" :filter="myFilter" />

  </q-input>
</q-field>

和客户数组:

clients: [{
        name: 'client 1',
        phone: '0545684562'
      }, {
        name: 'client 2',
        phone: '0556843544'
      }]

1 个答案:

答案 0 :(得分:0)

显然,列表中的每个对象都必须包含值/标签,因此我将数据更改为:

clients: [{
    label: 'client 1',
    value: 'client 1',
    phone: '0545684562'
  }, {
    label: 'client 2',
    value: 'client 2',
    phone: '0556843544'
  }]

和模板:

<q-field :error="$v.clientInfo.name.$error" error-label="Client name is required">
  <q-input placeholder="Start typing a client's name" float-label="Client Name" type="text" v-model="clientInfo.name" @blur="$v.clientInfo.name.$touch" :before="getIcon('perm_identity')" clearable>

      <q-autocomplete :min-characters="0" :value-field="v => `${ v.value}  (${ v.phone })`" :static-data="{field: 'value', list: clients}" :filter="myFilter" />

  </q-input>
</q-field>

它有效!