LoginSignup
11
8

More than 3 years have passed since last update.

実務で使った Vuetify おすすめコンポーネント 3 選!!!

Posted at
1 / 15

はじめに


v-chip


v-chip.gif


v-chip の良いところ

  • https://vuetifyjs.com/en/components/chips
  • ラベル、タグといった Web でよく使われる概念を表現しやすい。
  • 一覧から選択、インクリメンタルサーチ、新規作成、をバッチリサポート。

上限と新規追加の制御

  watch: {
    value(target: Object[]): void {
      // 上限設定
      if (target.length > 5) {
        this.$nextTick(() => target.pop());
        return;
      }

      const added = target[target.length - 1];
      // 新規追加の判断と制御
      if (typeof added === 'string') {
        if (!this.allowCreateLabel) {
          this.$nextTick(() => target.pop());
          return;
        }
      }
    }
  }

v-timeline


v-timeline.gif


v-timeline の良いところ


自分自身かどうかで左右を分けるを分ける

<v-timeline>
  <v-timeline-item
    v-for="comment in event.comments"
    :key="comment.commentId"
    :left="!isMe(comment)"
    :right="isMe(comment)"
  >
    <template v-slot:icon>
      <v-icon color="white">person</v-icon>
    </template>
    <v-card class="elevation-2">
      <!-- /// -->
    </v-card>
  </v-timeline-item>
</v-timeline>

v-calendar


v-calendar.png


v-calendar の良いところ


日毎に画像を並べて表示

<v-calendar ref="calendar" type="month">
  <template v-slot:day="{ present, date }">
    <template v-if="dateEventMap.has(date)">
      <template v-for="(event, i) in dateEventMap.get(date)">
        <nuxt-link
          :key="i"
          tag="img"
          :src="event.eventImageUrl"
          :width="`${100 / dateEventMap.get(date).length}%`"
          height="72"
          :to="`/events/${event.eventId}`"
        >
        </nuxt-link>
      </template>
    </template>
  </template>
</v-calendar>

まとめ

  • 紹介した以外にも素晴らしいコンポーネントがたくさんあります
  • ドキュメントも充実しているのでドンドン使っていきましょう!
  • https://vuetifyjs.com
11
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
11
8