Help us understand the problem. What is going on with this article?

VueのカレンダーコンポーネントのV-Calendarを触ってみた

VueのカレンダーコンポーネントのV-Calendarを触ってみました。
ドキュメントも分かりやすくて、使いやすそうな印象です。

公式ドキュメント:https://vcalendar.netlify.com/
公式GitHub:https://github.com/nathanreyes/v-calendar

install

下記に記載されている手順でinstallします。
自分はRecommendedの2A. Plugin Methodで使用しています。
https://vcalendar.netlify.com/guide/#installation

使い方

オプションを設定していないカレンダー

<template>
  <div>
    <div>シンプルなカレンダ</div>
    <vc-calendar />
  </div>
</template>

スクリーンショット 2019-05-19 11.49.42.png

カレンダーをカスタマイズ

slotが使えるのでカスタマイズもできます。
今回は下記を変更してみました。

  • headerのタイトルを変更
  • 土日の場合は文字色変更
  • 日にちの箇所にSVGを反映
<template>
  <div>day-content5</div>
  <vc-calendar :attributes='attributes5' style="width:500px;">
    <template slot='header-title' slot-scope='page'>
      {{page.yearLabel}}{{page.monthLabel}}
    </template>
    <template slot='day-content' slot-scope='props'>
      <div class="vc-day-content">
      <div v-bind:style="addStyleTextColor(props.day.weekday)">
        {{ props.day.day }}</div>
      </div>
      <div v-if="props.day.day % 2 ==0" style="text-align:center;">
        <img src="../assets/gatsby.svg">
      </div>
      <div v-else style="text-align:center">
        <img src="../assets/slack.svg">
      </div>
    </template>
  </vc-calendar>
</template>

<script>
export default {
  methods: {
    addStyleTextColor: function(weekday) {
      if (weekday === 1) {
        return {
          color: "red"
        };
      } else if (weekday === 7) {
        return {
          color: "#00c0ff"
        };
      }
    }
  }
};
</script>

スクリーンショット 2019-05-19 10.54.32.png

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away