最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

vue-week-picker實(shí)現(xiàn)支持按周切換的日歷

 更新時(shí)間:2019年06月26日 11:05:58   作者:chi1130  
這篇文章主要為大家詳細(xì)介紹了vue-week-picker實(shí)現(xiàn)支持按周切換的日歷,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue-week-picker實(shí)現(xiàn)按周切換的日歷的具體代碼,供大家參考,具體內(nèi)容如下

vue-week-picker

安裝

npm install vue-week-picker --save-dev

DEMO

功能

  • 自適應(yīng)式按周切換
  • 與DatePicker日期選擇器使用

結(jié)合Element-ui使用

效果


與vue-element結(jié)合組件,請(qǐng)轉(zhuǎn)到鏈接

使用

<VueWeekPicker @dateValue="dateValue" />

Or

<vue-week-picker @dateValue="dateValue" />

import VueWeekPicker from 'vue-week-picker';

export default {
 components: {
 VueWeekPicker
 }
}

Or

export default {
 components: {
 'vue-week-picker': VueWeekPicker
 }
}

代碼

<template>
 <div class="date">
 <el-row>
 <el-col :span="24">
 <div class="weeks">
  <!-- 日期 -->
  <ul class="days">
  <li @click="weekPre" class="prev-btn">
  <i class="fa fa-angle-left fa-icon" aria-hidden="true"></i>
  <span class="hidden-sm-and-down" style="margin-left: 5px;">上一周</span>
  </li>
  <li
  @click="pick(day, index)"
  v-for="(day, index) in days"
  :key="index"
  :class="{selected:index == tabIndex}"
  >
  <!--本月-->
  <span v-if="day.getMonth()+1 != currentMonth" class="other-month item-wrapper">
  <p>{{day | getWeekFormat}}</p>
  <span class="hidden-sm-and-down">{{ day | dateFormat }}</span>
  </span>
  <span v-else>
  <!--今天-->
  <span
   v-if="day.getFullYear() == new Date().getFullYear() && day.getMonth() == new Date().getMonth() && day.getDate() == new Date().getDate()"
   class="today-item"
  >今天</span>
  <span class="item-wrapper" v-else>
   <p>{{day | getWeekFormat}}</p>
   <span class="hidden-sm-and-down">{{ day | dateFormat }}</span>
  </span>
  </span>
  </li>
  <li @click="weekNext" class="next-btn">
  <span class="hidden-sm-and-down" style="margin-right: 5px;">下一周</span>
  <i class="fa fa-angle-right fa-icon" aria-hidden="true"></i>
  </li>
  <li>
  <span>
  <el-date-picker
   class="right-pick-btn"
   style="width: 100%"
   @change="pickDate"
   v-model="value1"
   type="date"
   placeholder="按日期查詢"
  ></el-date-picker>
  </span>
  </li>
  </ul>
 </div>
 </el-col>
 </el-row>
 <el-row>
 <el-col :span="20" :offset="2" class="time-range">
 <span
  @click="pickTime(time, index)"
  v-for="(time, index) in times"
  :key="index"
  :class="{active:index == tabTimeIndex}"
 >{{time}}</span>
 </el-col>
 </el-row>
 </div>
</template>
<script>
/* eslint-disable */
import moment from "moment";
export default {
 props: {
 dateValue: {
 type: String,
 default: moment(new Date()).format("YYYY-MM-DD")
 },
 timeValue: {
 type: String,
 default: "00:00"
 }
 },
 data() {
 return {
 currentYear: 1970, // 年份
 currentMonth: 1, // 月份
 currentDay: 1, // 日期
 currentWeek: 1, // 星期
 days: [],
 value1: "",
 tabIndex: null,
 tabTimeIndex: 0,
 times: [
 "00:00~06:00",
 "06:00~12:00",
 "12:00~18:00",
 "18:00~24:00",
 "今日節(jié)目"
 ]
 };
 },
 filters: {
 dateFormat(date) {
 return moment(date).format("YYYY-MM-DD");
 },
 getWeekFormat(date) {
 const weeksObj = {
 1: "周一",
 2: "周二",
 3: "周三",
 4: "周四",
 5: "周五",
 6: "周六",
 7: "周日"
 };
 let weekNumber = moment(date).isoWeekday();
 return weeksObj[weekNumber];
 }
 },

 mounted() {
 const index = _.findIndex(this.days, function(o) {
 // console.log('o: ', o.getDate());
 // console.log('new Date().getDate(): ', new Date().getDate());
 return o.getDate() === new Date().getDate();
 });
 console.log("index: ", index);
 this.tabIndex = index;
 },

 created() {
 this.initData(null);
 },

 methods: {
 formatDate(year, month, day) {
 const y = year;
 let m = month;
 if (m < 10) m = `0${m}`;
 let d = day;
 if (d < 10) d = `0$wppm3vysvbp`;
 return `${y}-${m}-$wppm3vysvbp`;
 },
 pickDate(date) {
 let newDate = moment(date).format("YYYY-MM-DD");
 this.$emit("dateValue", newDate);
 },
 initData(cur) {
 let date = "";
 if (cur) {
 date = new Date(cur);
 } else {
 date = new Date();
 }
 this.currentDay = date.getDate(); // 今日日期 幾號(hào)
 this.currentYear = date.getFullYear(); // 當(dāng)前年份
 this.currentMonth = date.getMonth() + 1; // 當(dāng)前月份
 this.currentWeek = date.getDay(); // 1...6,0 // 星期幾
 if (this.currentWeek === 0) {
 this.currentWeek = 7;
 }
 const str = this.formatDate(
 this.currentYear,
 this.currentMonth,
 this.currentDay
 ); // 今日日期 年-月-日
 this.days.length = 0;
 // 今天是周日,放在第一行第7個(gè)位置,前面6個(gè) 這里默認(rèn)顯示一周,如果需要顯示一個(gè)月,則第二個(gè)循環(huán)為 i<= 35- this.currentWeek
 /* eslint-disabled */
 for (let i = this.currentWeek - 1; i >= 0; i -= 1) {
 const d = new Date(str);
 d.setDate(d.getDate() - i);
 // console.log(y:" + d.getDate())
 this.days.push(d);
 }
 for (let i = 1; i <= 7 - this.currentWeek; i += 1) {
 const d = new Date(str);
 d.setDate(d.getDate() + i);
 this.days.push(d);
 }
 },

 // 上個(gè)星期
 weekPre() {
 const d = this.days[0]; // 如果當(dāng)期日期是7號(hào)或者小于7號(hào)
 d.setDate(d.getDate() - 7);
 this.initData(d);
 },

 // 下個(gè)星期
 weekNext() {
 const d = this.days[6]; // 如果當(dāng)期日期是7號(hào)或者小于7號(hào)
 d.setDate(d.getDate() + 7);
 this.initData(d);
 },

 // 上一個(gè)月 傳入當(dāng)前年份和月份
 pickPre(year, month) {
 const d = new Date(this.formatDate(year, month, 1));
 d.setDate(0);
 this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1));
 },

 // 下一個(gè)月 傳入當(dāng)前年份和月份
 pickNext(year, month) {
 const d = new Date(this.formatDate(year, month, 1));
 d.setDate(35);
 this.initData(this.formatDate(d.getFullYear(), d.getMonth() + 1, 1));
 },

 // 當(dāng)前選擇日期
 pick(date, index) {
 let newDate = moment(date).format("YYYY-MM-DD");
 this.$emit("dateValue", newDate);
 // console.log("index: ", index);
 this.tabIndex = index;
 // alert(
 // this.formatDate(date.getFullYear(), date.getMonth() + 1, date.getDate())
 // );
 },
 pickTime(time, index) {
 // console.log('time: ', time);
 let timeArr = [];
 timeArr.push(_.head(_.split(time, "~")));
 console.log("timeArr: ", timeArr);
 this.$emit("timeValue", _.join(timeArr), "");
 // console.log("index: ", index);
 this.tabTimeIndex = index;
 // alert(
 // this.formatDate(date.getFullYear(), date.getMonth() + 1, date.getDate())
 // );
 }
 }
};
</script>

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 淺談mvvm-simple雙向綁定簡(jiǎn)單實(shí)現(xiàn)

    淺談mvvm-simple雙向綁定簡(jiǎn)單實(shí)現(xiàn)

    本篇文章主要介紹了淺談mvvm-simple雙向綁定簡(jiǎn)單實(shí)現(xiàn),小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2018-04-04
  • vue中的el-form表單rule校驗(yàn)問(wèn)題(特殊字符、中文、數(shù)字等)

    vue中的el-form表單rule校驗(yàn)問(wèn)題(特殊字符、中文、數(shù)字等)

    這篇文章主要介紹了vue中的el-form表單rule校驗(yàn)問(wèn)題(特殊字符、中文、數(shù)字等),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-05-05
  • vue單頁(yè)面實(shí)現(xiàn)當(dāng)前頁(yè)面刷新或跳轉(zhuǎn)時(shí)提示保存

    vue單頁(yè)面實(shí)現(xiàn)當(dāng)前頁(yè)面刷新或跳轉(zhuǎn)時(shí)提示保存

    這篇文章主要介紹了vue單頁(yè)面實(shí)現(xiàn)當(dāng)前頁(yè)面刷新或跳轉(zhuǎn)時(shí)提示保存,在當(dāng)前頁(yè)面刷新或跳轉(zhuǎn)時(shí)提示保存并可取消刷新,以防止填寫的表單內(nèi)容丟失,感興趣的小伙伴們可以參考一下
    2018-11-11
  • vue中cookies的使用方式

    vue中cookies的使用方式

    這篇文章主要介紹了vue中cookies的使用方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2024-08-08
  • Electron+vite+vuetify項(xiàng)目搭建的流程和方法

    Electron+vite+vuetify項(xiàng)目搭建的流程和方法

    最近想用Electron來(lái)進(jìn)行跨平臺(tái)的桌面應(yīng)用開(kāi)發(fā),同時(shí)想用vuetify作為組件,于是想搭建一個(gè)這樣的開(kāi)發(fā)環(huán)境,這里分享下Electron+vite+vuetify項(xiàng)目搭建的流程和方法,感興趣的朋友一起看看吧
    2024-06-06
  • Vue基礎(chǔ)配置講解

    Vue基礎(chǔ)配置講解

    在本篇文章里小編給大家整理的是關(guān)于Vue基礎(chǔ)配置講解內(nèi)容,有興趣的朋友們可以學(xué)習(xí)下。
    2019-11-11
  • vue3.0組合式api的使用小結(jié)

    vue3.0組合式api的使用小結(jié)

    這篇文章主要介紹了vue3.0組合式api的使用小結(jié),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2022-08-08
  • Vue和React中快速使用Electron的簡(jiǎn)單教程

    Vue和React中快速使用Electron的簡(jiǎn)單教程

    Electron也可以快速地將你的網(wǎng)站打包成一個(gè)原生應(yīng)用發(fā)布,下面這篇文章主要給大家介紹了關(guān)于Vue和React中快速使用Electron的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),需要的朋友可以參考下
    2022-05-05
  • Vue-element中el-input輸入卡頓問(wèn)題的解決

    Vue-element中el-input輸入卡頓問(wèn)題的解決

    這篇文章主要介紹了Vue-element中el-input輸入卡頓問(wèn)題的解決方案,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-04-04
  • 淺談vue-props的default寫不寫有什么區(qū)別

    淺談vue-props的default寫不寫有什么區(qū)別

    這篇文章主要介紹了淺談vue-props的default寫不寫有什么區(qū)別,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧
    2020-08-08

最新評(píng)論

巴东县| 赣州市| 新津县| 贵南县| 兴城市| 呈贡县| 上杭县| 新巴尔虎右旗| 鹤山市| 赤水市| 浪卡子县| 清徐县| 泾川县| 景德镇市| 岫岩| 井陉县| 河池市| 凤冈县| 银川市| 思茅市| 化德县| 桐城市| 山东省| 安阳县| 上虞市| 丰城市| 吉安市| 赤峰市| 大庆市| 新宾| 巨野县| 古田县| 若羌县| 江安县| 高邑县| 临澧县| 朔州市| 恩施市| 东城区| 阿城市| 洪江市|