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

Vue編寫炫酷的時鐘插件

 更新時間:2022年08月30日 11:36:57   作者:lucky.麒麟  
這篇文章主要為大家詳細介紹了Vue編寫炫酷的時鐘插件,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了Vue編寫時鐘插件的具體代碼,供大家參考,具體內(nèi)容如下

效果圖

代碼奉上:

<template>
? ? <div class="clock">
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[0]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[0]"></div>
? ? ? ? </div>
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[1]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[1]"></div>
? ? ? ? </div>
? ? ? ? <em class="divider">:</em>
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[2]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[2]"></div>
? ? ? ? </div>
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[3]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[3]"></div>
? ? ? ? </div>
? ? ? ? <em class="divider">:</em>
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[4]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[4]"></div>
? ? ? ? </div>
? ? ? ? <div class="flip">
? ? ? ? ? ? <div class="digital front" :data-number="nextTimes[5]"></div>
? ? ? ? ? ? <div class="digital back" :data-number="nowTimes[5]"></div>
? ? ? ? </div>
? ? </div>
</template>

<script>
? ? export default {
? ? ? ? name: "ClockData",
? ? ? ? data () {
? ? ? ? ? ? return {
? ? ? ? ? ? ? ? duration: 650,
? ? ? ? ? ? ? ? nowTimes: [],
? ? ? ? ? ? ? ? nextTimes: [],
? ? ? ? ? ? ? ? timer: {},
? ? ? ? ? ? }
? ? ? ? },
? ? ? ? mounted() {
? ? ? ? ? ? this.initDate();
? ? ? ? ? ? this.timer = setInterval(() => {
? ? ? ? ? ? ? ? this.updateTime();
? ? ? ? ? ? }, 1000)
? ? ? ? },
? ? ? ? methods: {
? ? ? ? ? ? initDate() {
? ? ? ? ? ? ? ? let now = new Date();
? ? ? ? ? ? ? ? this.nowTimes = this.getTimeFromDate(new Date(now.getTime() - 1000));
? ? ? ? ? ? ? ? this.nextTimes = this.getTimeFromDate(now);
? ? ? ? ? ? },
? ? ? ? ? ? updateTime() {
? ? ? ? ? ? ? ? let now = new Date();
? ? ? ? ? ? ? ? let nowTimes = this.getTimeFromDate(new Date(now.getTime() - 1000));
? ? ? ? ? ? ? ? let nextTimes = this.getTimeFromDate(now);;
? ? ? ? ? ? ? ? for (let i = 0; i < 6; i++) {
? ? ? ? ? ? ? ? ? ? if (nowTimes[i] !== nextTimes[i]) {
? ? ? ? ? ? ? ? ? ? ? ? this.setSpin(i, nowTimes[i], nextTimes[i]);
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? }
? ? ? ? ? ? },
? ? ? ? ? ? setSpin(index, nowTime, nextTime) {
? ? ? ? ? ? ? ? let nodes = document.querySelectorAll(".flip");
? ? ? ? ? ? ? ? nodes[index].classList.add('running');
? ? ? ? ? ? ? ? this.nowTimes.splice(index, 1, nowTime);
? ? ? ? ? ? ? ? this.nextTimes.splice(index, 1, nextTime);
? ? ? ? ? ? ? ? setTimeout(() => {
? ? ? ? ? ? ? ? ? ? nodes[index].classList.remove('running');
? ? ? ? ? ? ? ? ? ? this.nowTimes.splice(index, 1, nextTime);
? ? ? ? ? ? ? ? }, this.duration)
? ? ? ? ? ? },
? ? ? ? ? ? getTimeFromDate(date) {
? ? ? ? ? ? ? ? let numTime = [];
? ? ? ? ? ? ? ? let timeStr = date
? ? ? ? ? ? ? ? ? ? .toTimeString()
? ? ? ? ? ? ? ? ? ? .slice(0, 8)
? ? ? ? ? ? ? ? ? ? .split(":")
? ? ? ? ? ? ? ? ? ? .join("");
? ? ? ? ? ? ? ? for (let i = 0; i < timeStr.length; i++) {
? ? ? ? ? ? ? ? ? ? numTime.push(parseInt(timeStr[i]));
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? return numTime;
? ? ? ? ? ? }
? ? ? ? },
? ? ? ? destroyed() {
? ? ? ? ? ? // 銷毀定時器
? ? ? ? ? ? clearInterval(this.timer);
? ? ? ? }
? ? }
</script>

<style scoped>
? ? .clock {
? ? ? ? display: flex;
? ? }
? ? .clock .divider {
? ? ? ? font-size: 66px;
? ? ? ? line-height: 102px;
? ? ? ? font-style: normal;
? ? }
? ? .clock .flip {
? ? ? ? position: relative;
? ? ? ? width: 60px;
? ? ? ? height: 100px;
? ? ? ? margin: 2px;
? ? ? ? font-size: 66px;
? ? ? ? line-height: 100px;
? ? ? ? text-align: center;
? ? ? ? background: white;
? ? ? ? border: 1px solid black;
? ? ? ? border-radius: 12px;
? ? }
? ? .clock .flip .digital::before, .clock .flip .digital::after {
? ? ? ? position: absolute;
? ? ? ? content: attr(data-number);
? ? ? ? left: 0;
? ? ? ? right: 0;
? ? ? ? color: white;
? ? ? ? background: black;
? ? ? ? overflow: hidden;
? ? ? ? -webkit-perspective: 160px;
? ? ? ? perspective: 160px;
? ? }
? ? .clock .flip .digital::before {
? ? ? ? top: 0;
? ? ? ? bottom: 50%;
? ? ? ? border-bottom: 1px solid #666;
? ? ? ? border-radius: 10px 10px 0 0;
? ? }
? ? .clock .flip .digital::after {
? ? ? ? top: 50%;
? ? ? ? bottom: 0;
? ? ? ? line-height: 0;
? ? ? ? border-radius: 0 0 10px 10px;
? ? }
? ? .clock .flip .back::before,
? ? .clock .flip .front::after {
? ? ? ? z-index: 1;
? ? }
? ? .clock .flip .back::after {
? ? ? ? z-index: 2;
? ? }
? ? .clock .flip .front::before {
? ? ? ? z-index: 3;
? ? }
? ? .clock .flip .back::after {
? ? ? ? -webkit-transform-origin: center top;
? ? ? ? transform-origin: center top;
? ? ? ? -webkit-transform: rotateX(0.5turn);
? ? ? ? transform: rotateX(0.5turn);
? ? }
? ? .clock .flip.running .front::before {
? ? ? ? -webkit-transform-origin: center bottom;
? ? ? ? transform-origin: center bottom;
? ? ? ? -webkit-animation: frontFlipDown 0.6s ease-in-out;
? ? ? ? animation: frontFlipDown 0.6s ease-in-out;
? ? ? ? -webkit-backface-visibility: hidden;
? ? ? ? backface-visibility: hidden;
? ? }
? ? .clock .flip.running .back::after {
? ? ? ? -webkit-animation: backFlipDown 0.6s ease-in-out;
? ? ? ? animation: backFlipDown 0.6s ease-in-out;
? ? }
? ? @-webkit-keyframes frontFlipDown {
? ? ? ? to {
? ? ? ? ? ? -webkit-transform: rotateX(0.5turn);
? ? ? ? ? ? transform: rotateX(0.5turn);
? ? ? ? }
? ? }
? ? @keyframes frontFlipDown {
? ? ? ? to {
? ? ? ? ? ? -webkit-transform: rotateX(0.5turn);
? ? ? ? ? ? transform: rotateX(0.5turn);
? ? ? ? }
? ? }
? ? @-webkit-keyframes backFlipDown {
? ? ? ? to {
? ? ? ? ? ? -webkit-transform: rotateX(0);
? ? ? ? ? ? transform: rotateX(0);
? ? ? ? }
? ? }
? ? @keyframes backFlipDown {
? ? ? ? to {
? ? ? ? ? ? -webkit-transform: rotateX(0);
? ? ? ? ? ? transform: rotateX(0);
? ? ? ? }
? ? }
</style>

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

相關(guān)文章

  • vue中view-model雙向綁定基礎(chǔ)原理解析

    vue中view-model雙向綁定基礎(chǔ)原理解析

    這篇文章主要介紹了vue中view-model雙向綁定基礎(chǔ)原理,文中給大家介紹了vue雙向綁定的原理總結(jié),本文通過示例代碼給大家介紹的非常詳細,需要的朋友可以參考下
    2022-10-10
  • vue組件以及父子組件通信方式

    vue組件以及父子組件通信方式

    這篇文章主要介紹了Vue組件化的基本概念,包括什么是組件化、Vue的組件化思想以及如何在Vue中注冊和使用組件,文章還詳細講解了如何進行父子組件之間的通信,包括父組件傳遞數(shù)據(jù)給子組件和子組件通過自定義事件將數(shù)據(jù)傳遞給父組件,文章最后通過一個綜合練習(xí)來鞏固所學(xué)知識
    2025-02-02
  • Vuex之理解Store的用法

    Vuex之理解Store的用法

    本篇文章主要介紹了Vuex之理解Store的用法,Store類就是存儲數(shù)據(jù)和管理數(shù)據(jù)方法的倉庫,實現(xiàn)方式是將數(shù)據(jù)和方法已對象形式傳入其實例中
    2017-04-04
  • 在vue項目中使用axios發(fā)送post請求出現(xiàn)400錯誤的解決

    在vue項目中使用axios發(fā)送post請求出現(xiàn)400錯誤的解決

    這篇文章主要介紹了在vue項目中使用axios發(fā)送post請求出現(xiàn)400錯誤的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-09-09
  • 詳解VUE的狀態(tài)控制與延時加載刷新

    詳解VUE的狀態(tài)控制與延時加載刷新

    本篇文章主要介紹了詳解VUE的狀態(tài)控制與延時刷新,實例分析了數(shù)據(jù)延時到展示的時候再去刷新的技巧,有興趣的可以了解一下。
    2017-03-03
  • Vue中router-link常用屬性使用案例講解

    Vue中router-link常用屬性使用案例講解

    這篇文章主要介紹了Vue中router-link常用屬性使用案例講解,本文結(jié)合實例代碼給大家介紹的非常詳細,對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2023-01-01
  • element table組件內(nèi)容換行的實現(xiàn)方案

    element table組件內(nèi)容換行的實現(xiàn)方案

    這篇文章主要介紹了element table組件內(nèi)容換行的實現(xiàn)方案,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • Vue.js遞歸組件構(gòu)建樹形菜單

    Vue.js遞歸組件構(gòu)建樹形菜單

    這篇文章主要介紹了用Vue.js遞歸組件構(gòu)建一個可折疊的樹形菜單的教學(xué)內(nèi)容,有興趣的朋友跟著學(xué)習(xí)下。
    2017-12-12
  • Element Alert警告的具體使用方法

    Element Alert警告的具體使用方法

    這篇文章主要介紹了Element Alert警告的具體使用方法,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • vue如何解決watch和methods值執(zhí)行順序問題

    vue如何解決watch和methods值執(zhí)行順序問題

    這篇文章主要介紹了vue如何解決watch和methods值執(zhí)行順序問題,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教
    2024-08-08

最新評論

通河县| 和林格尔县| 宣威市| 九龙县| 界首市| 惠来县| 黄石市| 泸定县| 清涧县| 北川| 奈曼旗| 贵德县| 平武县| 巴彦淖尔市| 海门市| 双柏县| 伊金霍洛旗| 亳州市| 观塘区| 九寨沟县| 克拉玛依市| 庄河市| 耒阳市| 弋阳县| 南昌县| 奉贤区| 沽源县| 大丰市| 根河市| 昌黎县| 红河县| 巍山| 沙洋县| 抚顺县| 丽水市| 牟定县| 平顺县| 麻阳| 临朐县| 冕宁县| 大化|