国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

自定義日歷.element-ui 修改時間選擇器樣式

這篇具有很好參考價值的文章主要介紹了自定義日歷.element-ui 修改時間選擇器樣式。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

一、自定義日歷

目錄

一、自定義日歷

二、時間選擇樣式自定義


先上效果圖

element日歷自定義,vue,前端

一、自定義日歷組件

element日歷自定義,vue,前端

已經(jīng)封裝成vue組件,可選擇切換年月:

<template>
  <div class="calendar-container">
    <div class="year flex items-center">
      <el-config-provider :locale="local">
        <el-date-picker
          v-model="selectDate"
          @change="rsetDate"
          type="month"
           class="testDate"
            popper-class="dark_form"
          style="width: 1.2rem"
          :placeholder="nowDate.year + '-' + (nowDate.month + 1)"
        >
        </el-date-picker>
      </el-config-provider>
      <div class="img"></div>
    </div>
    <ul class="week flex">
      <li v-for="(o, index) in 7" :key="o">{{ formatWeek(index) }}</li>
    </ul>
    <ul class="date">
      <li class="none-week dayli"  v-for="o in lastMonthDays" :key="o + 50">
        {{ lastMonthStartDay + o - 1 }}
      </li>
      <!-- 當(dāng)月 -->
      <span
        @click="clickEvent"
        v-for="day in nowMonthDays"
        :key="day"
        :class="day == nowDate.date ? 'dayli today' : 'dayli'"
      >
        {{ day }}
      </span>

      <li
        
        class="none-week dayli"
        v-for="day in 42 - lastMonthDays - nowMonthDays"
        :key="day + 100"
      >
        {{ day }}
      </li>
    </ul>
  </div>
</template>

<script>
import zhcn from "element-plus/lib/locale/lang/zh-cn";
//  let local = zhcn
export default {
  data() {
    return {
      local: zhcn,
      selectDate: [], //選擇日期列表
      nowDate: this.getDate(new Date()), //當(dāng)前設(shè)置時間 默認(rèn)為當(dāng)前系統(tǒng)時間
      today: "",
    };
  },
  computed: {
    lastMonthDays() {
      return this.startWeek();
    },
    lastMonthStartDay() {
      return (
        this.calcLastMonthDays(this.nowDate.year, this.nowDate.month) -
        (this.startWeek() - 1)
      );
    },
    nowMonthDays() {
      return this.calcDays(this.nowDate.year, this.nowDate.month);
    },
  },
  created() {
    if (this.setDate) {
      this.nowDate = this.getDate(this.setDate);
      this.settime(this.nowDate)
    }
    // var _this=this;
    // this.today=this.nowDate.date;
    // console.log(this.nowDate)
    // console.log(this.today)
  },
  methods: {
    // 傳輸時間給父組件 
    settime(){
      let arr=[this.nowDate.year+'-'+(this.nowDate.month+1),this.nowDate.date]// [2022-8,4]
      this.$emit('settime',arr)
    },
    //選擇月份
    rsetDate() {
      this.nowDate = this.getDate(this.selectDate);
      this.settime(this.nowDate)
    },
    getDate(date) {
      return {
        year: date.getFullYear(),
        month: date.getMonth(),
        day: date.getDay(),
        date: date.getDate(),
      };
    },
    formatWeek(day) {
      switch (day) {
        case 0:
          return "日";
        case 1:
          return "一";
        case 2:
          return "二";
        case 3:
          return "三";
        case 4:
          return "四";
        case 5:
          return "五";
        case 6:
          return "六";
      }
    },
    //判斷閏年
    isLeapYear(year) {
      return year % 4 == 0 && (year % 100 != 0 || year % 400 == 0);
    },
    //根據(jù)日子計算星期
    calcWeekend(year, month, day) {
      return new Date(year, month, day).getDay();
    },
    //計算某年某月的天數(shù)
    calcDays(year, month) {
      const monthDay = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
      if (this.isLeapYear(year) && month === 1) return 29;
      else return monthDay[month];
    },
    //計算上個月天數(shù)
    calcLastMonthDays(year, month) {
      if (month === 0) {
        return this.calcDays(year - 1, 11);
      } else {
        return this.calcDays(year, month - 1);
      }
    },
    //計算當(dāng)月開始星期
    startWeek() {
      return this.calcWeekend(this.nowDate.year, this.nowDate.month, 1);
    },
    //
    clickEvent(e) {
      let monthNo = this.nowDate.month;
      let month = monthNo <= 11 ? monthNo + 1 : 0;
      let date = {
        year: this.nowDate.year,
        month: month,
        week: new Date(
          this.nowDate.year,
          this.nowDate.month,
          e.target.innerText
        ).getDay(),
        day: Number(e.target.innerText),
      };
      // this.$emit("click-event", date);
      this.nowDate.date=date.day
      console.log(date.day);
      this.settime(this.nowDate)
    },
  },
};
</script>


<style  lang="scss" scoped>
.calendar-container {
  background: rgba(7, 25, 61, 0.39);
  border-radius: 4px;
  padding: 16px;
}
.year {
  position: relative;

  ::v-deep {
    .el-input__wrapper {
      border-radius: 4px;
      border: 1px solid #818ea9;
      box-shadow: none;
      margin-bottom: 16px;
    }
    .el-input__prefix {
      width: 33px;
    }
  }
  .img {
    position: absolute;
    top: 1.5px;
    z-index: 888;
    width: 33px;
    height: 27px;
    margin: 2px;
    // margin-right: 16px;
    background-image: url("~@/assets/imgs/landedEstate/public-resources/time.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }
  p {
    font-family: "HarmonyOS Sans";
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 19px;
    color: #ffffff;
    margin-right: 12px;
  }
}

.week {
  padding: 8px;
  justify-content: space-between;
  align-items: center;
  height: 40px;
  height: 40px;
  background: linear-gradient(
    270deg,
    rgba(19, 30, 52, 0.308) 0%,
    rgba(19, 30, 52, 0.7) 100%
  );
  border-radius: 4px;
  border-radius: 4px;
  margin-bottom: 12px;

  li {
    height: 24px;
    width: 32px;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    display: flex;
    flex-wrap: wrap;
    list-style: none;
    align-content: center;
    font-family: "HarmonyOS Sans";
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    letter-spacing: 0.02em;
  }
}
.date {
  justify-content: center;
  box-sizing: border-box;
  display: flex;
  flex-wrap: wrap;
  list-style: none;
  margin-top: 0;
  .dayli:nth-child(7n) {
    border-radius: 0px 2px 2px 0;
    // color: #22ff47;
  }
  .dayli:nth-child(7n + 1) {
    border-radius: 2px 0px 0px 2px;
    // color: #22ff47;
  }
  span {
    border-bottom: 1px;
    border-top: 1px;
    border-color: #818ea9;
    border-style: solid;
  }
  span:last-of-type {
    border-radius: 0px 2px 2px 0px;
    // color: #22ff47;
    border-right: 1px;
    border-color: #818ea9;
    border-style: solid;
  }
  span:first-of-type {
    border-radius: 0px 2px 2px 0px;
    // color: #ff229c;
    border-left: 1px;
    border-color: #818ea9;
    border-style: solid;
  }

  .today {
    background: linear-gradient(
      112.08deg,
      #8ab1ff 0.45%,
      #5985dd 61.64%,
      #3f6dcb 95.27%
    );
    box-shadow: -1px 3px 4px rgba(124, 149, 219, 0.6);
    border-radius: 4px;
    font-family: "HarmonyOS Sans";
    font-style: italic;
    font-weight: bolder;
    font-size: 16px;
    line-height: 20px;
    /* identical to box height, or 125% */

    text-align: center;
    letter-spacing: 0.02em;

    color: #ffffff;

    text-shadow: 0px 2px 4px #2366e9;
  }
  li,
  span {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    width: 43px;
    height: 35px;
    text-align: center;
    font-family: "HarmonyOS Sans";
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 20px;
    text-align: center;
    letter-spacing: 0.02em;
    color: #ffffff;
    background: #131e34b3;
  }
  li:hover {
    background: linear-gradient(
      112.08deg,
      #8ab1ff 0.45%,
      #5985dd 61.64%,
      #3f6dcb 95.27%
    );
    box-shadow: -1px 3px 4px rgba(124, 149, 219, 0.6);
    border-radius: 4px;
    cursor: pointer;
  }

  .none-week {
    font-family: "HarmonyOS Sans";
    font-style: normal;
    font-weight: 400;
    font-size: 16px;
    line-height: 20px;

    text-align: center;
    letter-spacing: 0.02em;

    color: #ffffff;

    opacity: 0.4;
  }
}
</style>

二、時間選擇樣式自定義

element日歷自定義,vue,前端

?因 element-UI的時間選擇器 el-date-picker 是將元素直接掛載到頁面的<body>中,而非自身元素下,所以使用?/deep/、?>>>、?::v-deep?等穿透無法定位到元素。

解決方案:

利用時間選擇器的popper-class屬性,設(shè)置樣式。

有2種方式:

  1. 創(chuàng)建style.scss,在該文件里進(jìn)行樣式的編寫,再引入
  2. 在APP.vue中加入樣式的編寫(根文件)
        <el-date-picker
          type="month"
          popper-class="dark_form" >
        </el-date-picker>

//效果圖對應(yīng)樣式



//   日期選擇彈窗樣式
  .el-picker__popper.el-popper[role="tooltip"] {
    border-color: #24386000;
  }
  .el-popper.is-light .el-popper__arrow::before {
    background: #131e34;
    border: none !important;
  }
  .dark_form {
    background: #131e34 !important;
    border: #131e34;
    .el-date-picker__header--bordered {
      border-bottom: solid 0.01rem #818ea9;
    }
    .el-picker__popper.el-popper[role="tooltip"] .el-popper__arrow::before {
      border: none !important;
    }
    .el-picker-panel__body {
      background: #131e34 !important;
    }
    .el-date-picker__header-label {
      color: #fbfbfb;
      font-family: "HarmonyOS Sans";
    }
    .el-picker-panel__icon-btn {
      color: #fbfbfb;
      font-family: "HarmonyOS Sans";
    }
    .el-month-table td .cell {
      color: #fbfbfb;
      font-family: "HarmonyOS Sans";
    }
	.el-year-table td .cell {
      color: #fbfbfb;
      font-family: "HarmonyOS Sans";
}
  }

搜索

復(fù)制文章來源地址http://www.zghlxwxcb.cn/news/detail-520026.html

到了這里,關(guān)于自定義日歷.element-ui 修改時間選擇器樣式的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進(jìn)行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • element-ui折疊面板怎么修改樣式

    element-ui折疊面板怎么修改樣式

    修改前 因為組件封裝,要使用樣式穿透來修改… 注意需要把需要樣式穿透的類單獨拿出來,不能包裹在scss格式的類里了 修改后 展開… 最后這個縫隙可以用邊框來填補(bǔ),至于偽類加橫杠最好不要用,因為展開和折疊的時候會出現(xiàn)一瞬間白線

    2024年02月12日
    瀏覽(39)
  • element-ui 自定義loading加載樣式

    element-ui 中的 loading 加載功能,默認(rèn)是全屏加載效果, 設(shè)置局部,需要自定義樣式,自定義的方法如下:

    2024年02月11日
    瀏覽(26)
  • 自定義element-ui走馬燈(輪播)樣式

    自定義element-ui走馬燈(輪播)樣式

    自定義el-carousel-item指示器樣式 把指示器變成圓點 效果圖: ?

    2024年02月13日
    瀏覽(30)
  • element-ui 時間日期選擇器限制選擇范圍

    element-ui 時間日期選擇器限制選擇范圍

    組件代碼 場景1:設(shè)置選擇今天及今天之后的日期 情景2: 設(shè)置選擇今天以及今天以前的日期 情景3: 設(shè)置選擇三個月之內(nèi)到今天的日期 情景4: 設(shè)置選擇最大范圍為30天

    2024年02月12日
    瀏覽(23)
  • element-ui日期選擇器時間差

    element-ui日期選擇器時間差

    #主要記錄三個問題 日期選擇器選擇時獲取到的格式相差八小時 當(dāng)日期格式為–拼接時,轉(zhuǎn)成時間戳?xí)嗖畎诵r(2023-03-09) DatePicker設(shè)置區(qū)域范圍和校驗(暫無,明天加上) 由于element-ui日期選擇器用的時間為世界標(biāo)準(zhǔn)時間,我們國家的標(biāo)準(zhǔn)時間為東八區(qū),所以會有8小時時間

    2024年02月08日
    瀏覽(24)
  • element-ui form表單自定義label的樣式、內(nèi)容

    element-ui form表單自定義label的樣式、內(nèi)容

    element-ui form表單自定義label的樣式、內(nèi)容

    2024年04月17日
    瀏覽(32)
  • vue修改element-ui日期下拉框datetimePicker的背景色樣式

    vue修改element-ui日期下拉框datetimePicker的背景色樣式

    在vue項目中,源datetimePicker的背景樣式,往往與項目背景不搭,需要修改。 ? 1.先在assets里面新建一個index.css文件來存儲全局樣式 2.在main.js里面導(dǎo)入這個css文件最后在里面加入我們想要的樣式 此時的效果如下圖 ? 3.在el-date-picker中設(shè)置樣式 4.設(shè)置對應(yīng)的背景樣式 得到下圖效果

    2024年02月11日
    瀏覽(100)
  • element-ui中 this.$confirm修改確定取消按鈕順序和樣式

    element-ui中 this.$confirm修改確定取消按鈕順序和樣式

    首先其他博客上說是給 this.$confirm中添加取消樣式,我試過了無效

    2024年02月14日
    瀏覽(33)
  • 【UI】 修改element-ui input輸入框placeholder提示信息、占位符的樣式

    【UI】 修改element-ui input輸入框placeholder提示信息、占位符的樣式

    如何修改 代碼如下: 效果 案例展示 vue2.x代碼 案例效果

    2024年02月15日
    瀏覽(25)
  • element-ui時間選擇器(DatePicker )數(shù)據(jù)回顯

    element-ui時間選擇器(DatePicker )數(shù)據(jù)回顯

    目錄 前言 一、element-ui時間選擇器(DatePicker )是什么? DatePicker 日期選擇器 二、返回數(shù)據(jù)格式 1.引入 總結(jié) 需求: element-ui時間選擇器(DatePicker )數(shù)據(jù)回顯,后臺返回數(shù)據(jù)時間,然后回顯到前臺展示。 效果: ? DatePicker 日期選擇器 用于選擇或輸入日期?https://element.eleme.c

    2024年01月19日
    瀏覽(24)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包