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

vue實現(xiàn)打卡功能

 更新時間:2022年08月29日 16:28:55   作者:心有陽光熱愛生活  
這篇文章主要為大家詳細介紹了vue實現(xiàn)打卡功能,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了vue實現(xiàn)打卡功能的具體代碼,供大家參考,具體內(nèi)容如下

記錄使用vue實現(xiàn)移動端日歷打卡樣式

template
compareToNow:與當前時間比較
-1:小于當前時間
0:今天
1:大于當前時間

<!-- @click="todo" 實現(xiàn)打卡功能 -->
<div v-if="compareToNow(item) === 1" @click="todo">{{ item.date }}</div>
<!-- @click="todo" 實現(xiàn)補卡功能 -->
?<div v-if="compareToNow(item) === -1" @click="todo" class="otherDay">
<template>
? <div>
? ? <div class="top-title">
? ? ? <div><span @click="lastMonth" class="link">?</span></div>
? ? ? <div><span>{{year}}年{{month}}月</span></div>
? ? ? <div><span @click="nextMonth" class="link">?</span></div>
? ? </div>
? ? <div class="container" style="border-bottom: 1px solid #cccccc">
? ? ? <div v-for="(item,index) in weeks" :key="index">{{ item }}</div>
? ? </div>
? ? <div class="container" style="padding: 1vh 1vh 3vh 1vh;">
? ? ? <div v-for="(item,index) in data" :key="index">
? ? ? ? <div v-if="compareToNow(item) === 0" style="color: #2d8cf0">{{ item.date }}</div>
? ? ? ? <div v-if="compareToNow(item) === 1">{{ item.date }}</div>
? ? ? ? <div v-if="compareToNow(item) === -1" class="otherDay">
? ? ? ? ? <div>{{ item.date }}</div>
? ? ? ? ? <div class="date-desc">補卡</div>
? ? ? ? </div>
? ? ? </div>
? ? </div>
? </div>
</template>

script

<script>
export default {
? data() {
? ? return {
? ? ? today:new Date(),
? ? ? now:new Date(),
? ? ? weeks:["日","一","二","三","四","五","六"],
? ? ? year:"",
? ? ? month:"",
? ? ? date:"",
? ? ? firstDay:"",
? ? ? data:[],
? ? };
? },
? mounted() {
? ? this.getNow();
? },
? methods:{
? ? getNow(){
? ? ? this.year = this.now.getFullYear();
? ? ? this.month = this.now.getMonth() + 1;
? ? ? this.date = this.now.getDate();
? ? ? this.now.setDate(1);
? ? ? this.firstDay = this.now.getDay();
? ? ? this.initData();
? ? },
? ? getMonthDay(month){
? ? ? if ([1,3,5,7,8,10,12].includes(month)) {
? ? ? ? return 31
? ? ? } else if ([4,6,9,11].includes(month)) {
? ? ? ? return 30
? ? ? } else if (month === 2) {
? ? ? ? // ?判斷當年是否為閏年
? ? ? ? if (
? ? ? ? ? (this.year % 4 === 0 && this.year % 100 !== 0) ||
? ? ? ? ? this.year % 400 === 0
? ? ? ? ) {
? ? ? ? ? return 29
? ? ? ? } else {
? ? ? ? ? return 28
? ? ? ? }
? ? ? }
? ? },
? ? initData(){
? ? ? this.data = [];
? ? ? let days = this.getMonthDay(this.month);
? ? ? for (let i = 0; i < this.firstDay; i++) {
? ? ? ? this.data.push({
? ? ? ? ? year:"",
? ? ? ? ? month:"",
? ? ? ? ? date:"",
? ? ? ? });
? ? ? }
? ? ? for (let i = 0; i < days; i++) {
? ? ? ? this.data.push(
? ? ? ? ? {
? ? ? ? ? ? year: this.year,
? ? ? ? ? ? month: this.month,
? ? ? ? ? ? date: i + 1,
? ? ? ? ? }
? ? ? ? );
? ? ? }
? ? },
? ? lastMonth(){
? ? ? this.now.setMonth(this.now.getMonth() - 1);
? ? ? this.getNow();
? ? },
? ? nextMonth(){
? ? ? this.now.setMonth(this.now.getMonth() + 1);
? ? ? this.getNow();
? ? },
? ? compareToNow(item){
? ? ? if (item.year && item.month && item.date) {
? ? ? ? let date1 = new Date();
? ? ? ? date1.setFullYear(item.year)
? ? ? ? date1.setMonth(item.month - 1)
? ? ? ? date1.setDate(item.date)
? ? ? ? date1.setHours(0)
? ? ? ? date1.setMinutes(0)
? ? ? ? date1.setSeconds(0)
? ? ? ? let now = new Date();
? ? ? ? now.setHours(0)
? ? ? ? now.setMinutes(0)
? ? ? ? now.setSeconds(0)

? ? ? ? if (date1.getTime() > now.getTime()){
? ? ? ? ? return 1
? ? ? ? }else if (date1.getTime() === now.getTime()){
? ? ? ? ? return 0
? ? ? ? }else if (date1.getTime() < now.getTime()){
? ? ? ? ? return -1
? ? ? ? }
? ? ? }
? ? }
? }
}
</script>

style

/* 背景圖片 background:url ?和 background-size 可注釋 */
<style scoped lang="less">
? .top-title{
? ? display: grid;
? ? grid-template-columns:repeat(3,1fr);
? ? grid-auto-rows:40px;
? ? grid-gap:1rem;
? ? background-color: #FFFFFF;
? ? border-bottom: 1px solid #cccccc;
? ? line-height: 40px;
? }
? .container{
? ? display: grid;
? ? grid-template-columns:repeat(7,1fr);
? ? grid-auto-rows:40px;
? ? grid-gap:1rem;
? ? background-color: #FFFFFF;
? ? line-height: 40px;

? ? div{
? ? ? text-align: center;
? ? }
? }
? .today{
? ? background: url("../assets/circle_success.png") no-repeat center center;
? ? background-size: 95% 95%;
? ? position: relative;
? }
? .otherDay{
? ? background: url("../assets/circle_error.png") no-repeat center center;
? ? background-size: 95% 95%;
? ? position: relative;
? }
? .link{
? ? font-size: 14px;
? ? color: #2d8cf0;
? }
? .date-desc{
? ? display: block;
? ? position: absolute;
? ? top: 6.8vw;
? ? left: 1.5vw;
? ? font-size: 2.3vw;
? ? color: green;
? }
</style>

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

相關(guān)文章

  • 簡單聊一聊axios配置請求頭content-type

    簡單聊一聊axios配置請求頭content-type

    最近在工作中碰到一個問題,后端提供的get請求的接口需要在request header設(shè)置,下面這篇文章主要給大家介紹了關(guān)于axios配置請求頭content-type的相關(guān)資料,需要的朋友可以參考下
    2022-04-04
  • Vue一個案例引發(fā)的遞歸組件的使用詳解

    Vue一個案例引發(fā)的遞歸組件的使用詳解

    這篇文章主要介紹了Vue一個案例引發(fā)的遞歸組件的使用,本文主要給大家展示如何在項目中使用遞歸組件,本文給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下
    2018-11-11
  • vue 解決form表單提交但不跳轉(zhuǎn)頁面的問題

    vue 解決form表單提交但不跳轉(zhuǎn)頁面的問題

    今天小編就為大家分享一篇vue 解決form表單提交但不跳轉(zhuǎn)頁面的問題,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2019-10-10
  • 淺談在vue項目中如何定義全局變量和全局函數(shù)

    淺談在vue項目中如何定義全局變量和全局函數(shù)

    本篇文章主要介紹了淺談在vue項目中如何定義全局變量和全局函數(shù),具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2017-10-10
  • elementUI Tree 樹形控件的官方使用文檔

    elementUI Tree 樹形控件的官方使用文檔

    這篇文章主要介紹了elementUI Tree 樹形控件的官方使用文檔,用清晰的層級結(jié)構(gòu)展示信息,可展開或折疊。小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2019-04-04
  • 詳解vuex中mutation/action的傳參方式

    詳解vuex中mutation/action的傳參方式

    這篇文章主要介紹了詳解vuex中mutation/action的傳參方式,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-08-08
  • vue :src 文件路徑錯誤問題的解決方法

    vue :src 文件路徑錯誤問題的解決方法

    這篇文章主要介紹了vue :src 文件路徑錯誤問題的簡單解決方法,本文分步驟給大家介紹的非常詳細,感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05
  • vue3使用video.js播放m3u8格式視頻的操作指南

    vue3使用video.js播放m3u8格式視頻的操作指南

    有時候我們需要播放 m3u8 格式的視頻,或者實現(xiàn)視頻播放器更多定制化需求,HTML 的 video 元素無法實現(xiàn)這些需求,這時候可以考慮使用 Video.js,本文給大家介紹了vue3使用video.js播放m3u8格式視頻的操作指南,需要的朋友可以參考下
    2024-07-07
  • 詳解使用vue-admin-template的優(yōu)化歷程

    詳解使用vue-admin-template的優(yōu)化歷程

    這篇文章主要介紹了詳解使用vue-admin-template的優(yōu)化歷程,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2018-05-05
  • vue如何使用moment處理時間戳轉(zhuǎn)換成日期或時間格式

    vue如何使用moment處理時間戳轉(zhuǎn)換成日期或時間格式

    這篇文章主要給大家介紹了關(guān)于vue如何使用moment處理時間戳轉(zhuǎn)換成日期或時間格式的相關(guān)資料,文中通過示例代碼介紹的非常詳細,對大家學(xué)習(xí)或者vue具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下
    2022-03-03

最新評論

沂水县| 抚顺县| 南宫市| 德令哈市| 郧西县| 滁州市| 石景山区| 仲巴县| 延安市| 怀仁县| 泸水县| 阿尔山市| 靖西县| 镇沅| 茶陵县| 中宁县| 开远市| 湘西| 沂水县| 甘孜县| 阿合奇县| 无锡市| 木兰县| 宁化县| 光泽县| 台州市| 河西区| 申扎县| 贵阳市| 海伦市| 七台河市| 屏边| 毕节市| 静安区| 广州市| 望都县| 葵青区| 德庆县| 永吉县| 红原县| 平遥县|