๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ

Web/Vue

Vuetify, refs

๋ฐ˜์‘ํ˜•

tab์ด null ๋กœ ์ดˆ๊ธฐํ™” ๋˜์–ด์žˆ์œผ๋‹ˆ๊นŒ, tab ์•ˆ์˜ <v-data-table> ref์— ์ ‘๊ทผ์ด ์•ˆ๋จ

tab: 'tab-1' ๋กœ ๋ฐ”๊พธ๊ณ  ๋‹ค์‹œ ์‹œ๋„

      <v-tabs-items v-model="tab">
        <v-tab-item value="tab-1">
          <v-data-table
            :headers="headers"
            :items="desserts"
            item-key="name"
            sort-by="name"
            group-by="category"
            class="elevation-1"
            show-group-by
            ref="table"
          ></v-data-table>
        </v-tab-item>
      </v-tabs-items>
<script>
  var vm = new Vue({
    el: '#app',
    vuetify: new Vuetify(),
    data () {
      return {
        tab: null,
        headers: [
          {
            text: 'Dessert (100g serving)',
            align: 'start',
            value: 'name',
            groupable: false,
          },
          { text: 'Category', value: 'category', align: 'right' },
          { text: 'Dairy', value: 'dairy', align: 'right' },
        ],
        desserts: [
          {
            name: 'Frozen Yogurt',
            category: 'Ice cream',
            dairy: 'Yes',
          },
          {
            name: 'Ice cream sandwich',
            category: 'Ice cream',
            dairy: 'Yes',
          },
          {
            name: 'Eclair',
            category: 'Cookie',
            dairy: 'Yes',
          },
          {
            name: 'Cupcake',
            category: 'Pastry',
            dairy: 'Yes',
          },
          {
            name: 'Gingerbread',
            category: 'Cookie',
            dairy: 'No',
          },
        ],
      }
    },
    mounted () {
      let table = this.$refs.table;
      console.log(this.$refs)
      let keys = Object.keys(table.$vnode.componentInstance.openCache);
      keys.forEach(x => {
        table.$vnode.componentInstance.openCache[x] = false;
      })
    }
  })
</script>โ€‹

 

 

๋ฐ˜์‘ํ˜•

'Web > Vue' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

[Vue.js] CLI ์„ค์น˜ํ•˜๊ธฐ  (0) 2020.12.14
[Vue.js] Vuetify, v-data-table  (0) 2020.12.02
[Vue] Vuetify Quick Start  (0) 2020.07.14
[Vue] Delimiters ๋ณ€๊ฒฝ  (0) 2020.07.13
[Vue] ์‹œ์ž‘ํ•˜๊ธฐ!  (0) 2020.07.13