From 95fc0103c15194ba810b82c91fc12fb50e7ad783 Mon Sep 17 00:00:00 2001 From: liuqimichale <123456lq> Date: Tue, 12 Mar 2019 11:56:39 +0800 Subject: [PATCH] 收入信息 --- src/components/VIncome.vue | 15 ++++++++++----- src/components/base/BarEcharts.vue | 13 +++++++++++++ src/components/base/barChart.vue | 202 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/utils/debounce.js | 34 ++++++++++++++++++++++++++++++++++ 4 files changed, 259 insertions(+), 5 deletions(-) create mode 100644 src/components/base/BarEcharts.vue create mode 100644 src/components/base/barChart.vue create mode 100644 src/utils/debounce.js diff --git a/src/components/VIncome.vue b/src/components/VIncome.vue index ed39cd7..c2d9918 100644 --- a/src/components/VIncome.vue +++ b/src/components/VIncome.vue @@ -6,7 +6,7 @@ 总计
- +
@@ -15,20 +15,24 @@ + + diff --git a/src/components/base/barChart.vue b/src/components/base/barChart.vue new file mode 100644 index 0000000..b078b6a --- /dev/null +++ b/src/components/base/barChart.vue @@ -0,0 +1,202 @@ + + + diff --git a/src/utils/debounce.js b/src/utils/debounce.js new file mode 100644 index 0000000..31af964 --- /dev/null +++ b/src/utils/debounce.js @@ -0,0 +1,34 @@ +export function debounce(func, wait, immediate) { + let timeout, args, context, timestamp, result + + const later = function() { + // 据上一次触发时间间隔 + const last = +new Date() - timestamp + + // 上次被包装函数被调用时间间隔last小于设定时间间隔wait + if (last < wait && last > 0) { + timeout = setTimeout(later, wait - last) + } else { + timeout = null + // 如果设定为immediate===true,因为开始边界已经调用过了此处无需调用 + if (!immediate) { + result = func.apply(context, args) + if (!timeout) context = args = null + } + } + } + + return function(...args) { + context = this + timestamp = +new Date() + const callNow = immediate && !timeout + // 如果延时不存在,重新设定延时 + if (!timeout) timeout = setTimeout(later, wait) + if (callNow) { + result = func.apply(context, args) + context = args = null + } + + return result + } +} -- libgit2 0.21.4