Display selected country flags in Vue
P粉464082061
P粉464082061 2023-12-28 16:51:54
0
1
480

After selecting a country, the national flag must be displayed in the selection options. I need to do this in Vue.

new Vue({
el: '#app',
vuetify: new Vuetify(),
data: {
select: null,
countries: [
  {
    name: "Albania",
    flag: "em-flag-al"
  },
  {
    name: "Anguilla",
    flag: "em-flag-ai"
  }
 ],
 }
 })


<div id="app">
 <v-app class="container">
<v-select
  v-model="select"
  :items="countries"
  label="Select"
  item-text="name"
>
  <template v-slot:item="slotProps" >
    <i :class="['mr-2', 'em', slotProps.item.flag]"></i>
    {{slotProps.item.name}}
  </template>
 </v-select>
 </v-app>
 </div>

Or you can refer to https://codepen.io/aaha/pen/ZEbRwpy?editors=1010

P粉464082061
P粉464082061

reply all(1)
P粉087074897

You can use another slot to choose :)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template