Answer a question

I'm trying to set up a vuetify chip group and two way bind the selection to a data variable called selected.

enter image description here

This should be a relatively simple operation yet I cant find any documentation on how to do this. Any help would be greatly appreciated.

new Vue({
el: '#app',
vuetify: new Vuetify(),
data: () => ({
   selected:'Vacation',
   tags: [
    'Work',
    'Home Improvement',
    'Vacation',
    'Food',
    'Drawers',
    'Shopping',
    'Art',
    'Tech',
    'Creative Writing',
      ],
    }),
   })

Answers

A Basic v-model on v-chip-group will bind the chip selection value.

Basic "hello world" example:

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    selection: '06',
    sizes: [
      '04', '06', '08', '10', '12', '14',
    ],
  }),
})
<script src="https://cdn.jsdelivr.net/npm/vue@2.x/dist/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.2.28/dist/vuetify.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/vuetify@2.2.28/dist/vuetify.min.css" rel="stylesheet"/>


<div id="app">
  <v-app id="inspire">
    <v-chip-group
                  v-model="selection"
                  active-class="deep-purple--text text--accent-5"
                  >
      <v-chip v-for="size in sizes" :key="size" :value="size">
        {{ size }}
      </v-chip>
    </v-chip-group>
    <h2>{{selection}}</h2>
  </v-app>
</div>

Related:

  • Vue v-model

  • Vuetify chip-groups

Logo

Vue社区为您提供最前沿的新闻资讯和知识内容

更多推荐