Autocomplete Multiple default value not showing

UI Components for Vue
Post Reply
GoodOmen
Posts: 1
Joined: 07 Jun 2022, 15:24

07 Jun 2022, 15:33

Hi,

Using both modelValue or v-model to show default value is not showing. Please help.

Code: Select all

<template>
  <div>
    <div>
      <AutoComplete
        multiple
        v-model="selectedCountry1"
        :suggestions="filteredCountries"
        @complete="searchCountry($event)"
        field="name"
      />
    </div>
  </div>
</template>

<script>
import CountryService from "./service/CountryService";

export default {
  data() {
    return {
      selectedCountry1: { name: "Afghanistan", code: "AF" },
    };
  },
  countryService: null,
  created() {
    this.countryService = new CountryService();
  },
  mounted() {
    this.countryService.getCountries().then((data) => (this.countries = data));
  }
};
</script>
https://codesandbox.io/s/tender-kapitsa ... .vue:0-629

tugce.kucukoglu
Posts: 404
Joined: 23 Oct 2020, 09:28

01 Jul 2022, 14:50

In your example 'selectedCountries' is array of the strings, but must be an array of the objects.

Post Reply

Return to “PrimeVue”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 2 guests