LoginSignup
2
1

More than 3 years have passed since last update.

bootstap-vueで一定時間経過すると色が変わるあいつをつくってみた

Posted at

概要

javascriptのお勉強がてらに、既存のページをVue.js化して遊んでいますが、その過程でホームページのお知らせよくあるあいつを作ってみました。
勉強記録と忘備録を兼ねてここに公開します

色が変わるやつ.png

つかったもの

できたもの

DateBadge.vue
<template>
  <b-badge :variant="Valobject(date)">{{ date }}</b-badge>
</template>
<script>
//一週間過ぎたら色を変えるすごいやつだよ
//dayjsを使っているので利用する場合はいれてね
export default {
  name: "DataBadge",
  props: {
    date: String
  },
  methods: {
    Valobject(date) {
      return this.$dayjs(date).isBefore(
        this.$dayjs()
          .subtract(1, "week") //期間を変えたいならこの辺いじってね
          .format("YYYY/MM/DD")//日付の表示形式
      )
        ? "lighten"
        : "danger";
    }
  }
};
</script>
2
1
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
2
1