From 41068b9afee4e53ba64a37b43b187f5d2c72d12f Mon Sep 17 00:00:00 2001 From: "453530270@qq.com" Date: Wed, 26 Jul 2023 17:26:34 +0800 Subject: [PATCH] =?UTF-8?q?=E5=BB=BA=E7=AB=8B=E6=8C=87=E4=BB=A4=E7=9A=84?= =?UTF-8?q?=E5=BD=A2=E5=BC=8F=E8=B0=83=E6=95=B4=E5=8A=A8=E7=94=BB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/change.js | 27 +++++++++++++++++++++++++++ src/main.js | 4 +++- src/views/HomeView.vue | 6 +----- 3 files changed, 31 insertions(+), 6 deletions(-) create mode 100644 src/components/change.js diff --git a/src/components/change.js b/src/components/change.js new file mode 100644 index 0000000..29ca6e0 --- /dev/null +++ b/src/components/change.js @@ -0,0 +1,27 @@ +const directive ={ + // + inserted(el,bindding){ + console.log("DIAOMAO,你能看到我") + console.log(el,bindding) + let count =0 ;//init val + let num = el.innerText // 获取页面的值 + let rate = 30 //定时器时间间隔 + let average = num/(bindding.value/rate); // 每次定时器跳动的值 + // + const timer = setInterval(()=>{ + // + count += average + el.innerText = count.toFixed(0) + + if(count>num) { + count=num + el.innerText = count + // + clearInterval(timer) + } + },rate); + + }, +} + +export default directive; \ No newline at end of file diff --git a/src/main.js b/src/main.js index 37c48e5..aef19be 100644 --- a/src/main.js +++ b/src/main.js @@ -1,16 +1,18 @@ import { createApp } from 'vue' import App from './App.vue' import router from './router' -import store from './store' //axios import axios from 'axios' +import directive from './components/change' const app = createApp(App) app.use(router) app.provide('$axios', axios) app.mount("#app") +app.directive("change",directive) +app.config.productionTip =false // createApp(App).use(store) // .use(router) // .mount('#app') \ No newline at end of file diff --git a/src/views/HomeView.vue b/src/views/HomeView.vue index d4a62a7..04d5750 100644 --- a/src/views/HomeView.vue +++ b/src/views/HomeView.vue @@ -641,11 +641,7 @@ export default { that.day_num = tmpdata.day.noRepeatInNum that.week_num = tmpdata.week.noRepeatInNum that.mon_num = tmpdata.month.noRepeatInNum - that.year_num = tmpdata.year.noRepeatInNum - // 增加数字动画效果 - numGrow(ycdn,tmpdata.day.noRepeatInNum) - - + // that.year_num = tmpdata.year.noRepeatInNum }); },