欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue實(shí)現(xiàn)抖音時(shí)間轉(zhuǎn)盤

 更新時(shí)間:2019年09月08日 09:11:50   作者:沙鑫741  
這篇文章主要為大家詳細(xì)介紹了vue實(shí)現(xiàn)抖音時(shí)間轉(zhuǎn)盤,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了vue實(shí)現(xiàn)抖音時(shí)間轉(zhuǎn)盤的具體代碼,供大家參考,具體內(nèi)容如下

做了一個(gè)抖音時(shí)間轉(zhuǎn)盤,還挺簡單的,可能我做的很粗糙

用vue做的 才160行代碼。

其實(shí)很簡單 只是大部分人被這個(gè)圓給迷惑了

這個(gè)圓就是用簡單css3就能做 通過rotate來修改計(jì)算就能展示出來了。

然后貼代碼。

<template>
 <div class="main">
  <div class="timeBox">
   <div class="yearBox box">{{year}}</div>
   <div class="dayBox box" :style="'transform: rotate('+(360/day.length)*curDay+'deg)'">
    <ul class="container">
     <li
      v-for="(v,i) in day"
      :key="i"
      :style="'transform: rotate('+(-360/day.length) * (i+1) +'deg);transform-origin: -100% 50% 0px;margin-left:150px;margin-top:90px'"
     >{{v}}</li>
    </ul>
   </div>
   <div class="hourBox box" :style="'transform: rotate('+(-360/hour.length)*curHour+'deg)'">
    <ul class="container">
     <li
      v-for="(v,i) in hour"
      :key="i"
      :style="'transform: rotate('+(360/hour.length)*i+'deg);transform-origin: -200% 50% 0px;margin-left:300px;margin-top:190px'"
     >{{v}}</li>
    </ul>
   </div>
   <div class="minutesBox box" :style="'transform: rotate('+(-360/minutes.length)*curMin+'deg)'">
    <ul class="container">
     <li
      v-for="(v,i) in minutes"
      :key="i"
      :style="'transform: rotate('+(360/minutes.length)*i+'deg);transform-origin: -300% 50% 0px;margin-left:450px;margin-top:290px'"
     >{{v}}</li>
    </ul>
   </div>
    <div class="secondBox" :style="'transform: rotate('+(-360/seconds.length)*curSec+'deg)'">
    <ul class="container">
     <li
      v-for="(v,i) in seconds"
      :key="i"
      :style="'transform: rotate('+(360/seconds.length)*i+'deg);transform-origin: -400% 50% 0px;margin-left:600px;margin-top:390px'"
     >{{v}}</li>
    </ul>
   </div>
  </div>
 </div>
</template>
<script>
export default {
 data: function () {
  return {
   data: ['零', '壹', '貳', '叁', '肆', '伍', '陸', '柒', '捌', '玖', '拾', '佰', '仟', '萬'],
   hour: [],
   curHour: 0,
   day: [],
   curDay: 0,
   minutes: [],
   curMin: 0,
   seconds: [],
   curSec: 0,
   year: ''
  }
 },
 created () {
  this.dealData()
  this.seconds = JSON.parse(JSON.stringify(this.minutes))
  var sky = ['', '辛', '壬', '癸', '甲', '乙', '丙', '丁', '戊', '己', '庚']
  var land = ['', '酉', '戌', '亥', '子', '丑', '寅', '卯', '辰', '巳', '午', '未', '申']
  var one = new Date().getFullYear() % 10
  var two = new Date().getFullYear() % 12
  this.year = sky[one] + land[two]
  setInterval(() => {
   this.getTime()
  }, 1000)
 },
 methods: {
  dealData () { // 生成數(shù)據(jù)
   // 星期
   for (let i = 0; i < 7; i++) {
    this.day.push('星期' + this.data[i + 1])
   }
   // 小時(shí)
   for (let i = 0; i < 24; i++) {
    if (i < 11) {
     this.hour.push(this.data[i])
    } else {
     this.hour.push((parseInt(i / 10) > 1 ? this.data[parseInt(i / 10)] : '') + '拾' + (parseInt(i % 10) !== 0 ? this.data[i % 10] : ''))
    }
   }
   // 分鐘
   for (let i = 0; i < 60; i++) {
    if (i < 11) {
     this.minutes.push(this.data[i])
    } else {
     this.minutes.push((parseInt(i / 10) > 1 ? this.data[parseInt(i / 10)] : '') + '拾' + (parseInt(i % 10) !== 0 ? this.data[i % 10] : ''))
    }
   }
  },
  getTime () { // 獲取時(shí)間
   var now = new Date()
   this.curSec = now.getSeconds()
   this.curDay = now.getDay()
   this.curMin = now.getMinutes()
   this.curHour = now.getHours()
  }
 }
}
</script>
<style lang="scss" scoped>
.box{
 position: absolute;
 transition: 1s;
}
.main{
 width: 100%;
 height: 100vh;
 overflow: hidden;
 background: #ccc;
}
.yearBox{
 top: 50%;
 left: 50%;
 height: 40px;
 width: 40px;
 margin-top: -20px;
 margin-left: -20px;
 line-height: 40px;
 text-align: center;
 font-size: 18px;
}
.timeBox{
 width: 800px;
 height: 800px;
 margin: 0 auto;
 position: relative;
}
.dayBox {
 width: 200px;
 height: 200px;
 top: 300px;
 left: 300px;
}
.hourBox {
 width: 400px;
 height: 400px;
 top: 200px;
 left: 200px;
}
.minutesBox {
 width: 600px;
 height: 600px;
 top: 100px;
 left: 100px;
}
.secondBox {
 width: 800px;
 height: 800px;
 top: 0;
 left: 0;
 position: absolute;
}
.container {
  overflow:auto;
  li {
   width: 50px;
   height: 20px;
   font-size: 12px;
   position: absolute;
  }
 }
</style>

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

相關(guān)文章

  • Vue3跨域解決方案實(shí)例詳解

    Vue3跨域解決方案實(shí)例詳解

    這篇文章主要介紹了Vue3跨域解決方案詳解,需要的朋友可以參考下
    2023-01-01
  • vue中如何使用唯一標(biāo)識uuid(uuid.v1()-時(shí)間戳、uuid.v4()-隨機(jī)數(shù))

    vue中如何使用唯一標(biāo)識uuid(uuid.v1()-時(shí)間戳、uuid.v4()-隨機(jī)數(shù))

    這篇文章主要給大家介紹了關(guān)于vue中如何使用唯一標(biāo)識uuid(uuid.v1()-時(shí)間戳、uuid.v4()-隨機(jī)數(shù))的相關(guān)資料,當(dāng)使用Vue.js生成UUID時(shí),我們可以使用uuid庫來幫助我們生成通用唯一標(biāo)識符(UUID),需要的朋友可以參考下
    2023-12-12
  • vue webpack重寫cookie路徑的方法

    vue webpack重寫cookie路徑的方法

    webpack提供的反向代理服務(wù)器在開發(fā)階段非常方便,幾行簡單的代碼配置就可以使用反向代理功能,包括路徑重寫、cookie處理等。這篇文章主要介紹了vue webpack重寫cookie路徑,需要的朋友可以參考下
    2019-07-07
  • vue使用keep-alive保持滾動(dòng)條位置的實(shí)現(xiàn)方法

    vue使用keep-alive保持滾動(dòng)條位置的實(shí)現(xiàn)方法

    這篇文章主要介紹了vue使用keep-alive保持滾動(dòng)條位置的實(shí)現(xiàn)方法,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-04-04
  • 父組件中vuex方法更新state子組件不能及時(shí)更新并渲染的完美解決方法

    父組件中vuex方法更新state子組件不能及時(shí)更新并渲染的完美解決方法

    這篇文章主要介紹了父組件中vuex方法更新state子組件不能及時(shí)更新并渲染的完美解決方法,需要的朋友可以參考下
    2018-04-04
  • Vuex狀態(tài)機(jī)的快速了解與實(shí)例應(yīng)用

    Vuex狀態(tài)機(jī)的快速了解與實(shí)例應(yīng)用

    Vuex是專門為Vuejs應(yīng)用程序設(shè)計(jì)的狀態(tài)管理工具,這篇文章主要給大家介紹了關(guān)于Vuex狀態(tài)機(jī)快速了解與實(shí)例應(yīng)用的相關(guān)資料,需要的朋友可以參考下
    2021-06-06
  • Vue.js雙向綁定實(shí)現(xiàn)原理詳解

    Vue.js雙向綁定實(shí)現(xiàn)原理詳解

    這篇文章主要為大家詳細(xì)介紹了Vue.js雙向綁定實(shí)現(xiàn)原理,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2016-12-12
  • vuejs父子組件之間數(shù)據(jù)交互詳解

    vuejs父子組件之間數(shù)據(jù)交互詳解

    這篇文章主要為大家詳細(xì)介紹了vuejs父子組件之間的數(shù)據(jù)交互,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-08-08
  • Vue深入講解數(shù)據(jù)響應(yīng)式原理

    Vue深入講解數(shù)據(jù)響應(yīng)式原理

    應(yīng)用會對用戶的操作進(jìn)行反饋,就叫響應(yīng)式,數(shù)據(jù)變化會實(shí)時(shí)改變UI,就叫數(shù)據(jù)響應(yīng)式,修改Vue實(shí)例中的數(shù)據(jù)時(shí),視圖會重新渲染,就是Vue的數(shù)據(jù)響應(yīng)式
    2022-05-05
  • Vue拖拽組件開發(fā)實(shí)例詳解

    Vue拖拽組件開發(fā)實(shí)例詳解

    本文重點(diǎn)給大家介紹Vue拖拽組件開發(fā)實(shí)例,拖拽的原理是手指在移動(dòng)的過程中,實(shí)時(shí)改變元素的位置即top和left值,使元素隨著手指的移動(dòng)而移動(dòng)。對實(shí)例代碼感興趣的朋友跟隨腳本之家小編一起學(xué)習(xí)吧
    2018-05-05

最新評論