Skip to content

[MultiSelect] How to set default selected items? #239

Discussion options

You must be logged in to vote

Hi,

Yes, it can be

<MultiSelect v-model="selectedCities" :options="cities" optionLabel="name" />


<script setup>
import { ref, onMounted } from 'vue';

const selectedCities = ref(null);

const cities = ref([
  { name: 'New York', code: 'NY' },
  { name: 'Rome', code: 'RM' },
  { name: 'London', code: 'LDN' },
  { name: 'Istanbul', code: 'IST' },
  { name: 'Paris', code: 'PRS' },
]);

onMounted(() => {
  selectedCities.value = [cities.value[0]];
});
</script>

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@ristaum
Comment options

Answer selected by tugcekucukoglu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants