From f2dbe98c4fe8342e3c5450064b39b6bd3060222c Mon Sep 17 00:00:00 2001 From: kevin jiang Date: Wed, 13 May 2020 06:40:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A6=96=E9=A1=B5=E5=AE=9A?= =?UTF-8?q?=E6=97=B6=E5=99=A8=E8=B0=83=E6=95=B45=E5=88=86=E9=92=9F?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=B8=80=E6=AC=A1=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/CustomerView.vue | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/pages/CustomerView.vue b/src/pages/CustomerView.vue index 3f95d5f..ff2ea7b 100644 --- a/src/pages/CustomerView.vue +++ b/src/pages/CustomerView.vue @@ -240,6 +240,7 @@ {'date': '1/1', '新增好友': 30, '新增好友(去重)': 25}, ] }, + timer: null } }, computed: { @@ -273,9 +274,11 @@ this.dateBtnClick('今日'); this.timingRefresh(); }, - destroyed: function(){ - //销毁自动刷新 - clearInterval(this.intervalId); + // 页面销毁清除定时器 + beforeDestroy() { + if (this.timer){ + clearInterval(this.timer); + } }, methods: { //页面重绘 @@ -509,10 +512,9 @@ //定时刷新 timingRefresh: function () { let that = this; - let intervalId = setInterval(function () { + that.timer = setInterval(function () { that.dateBtnClick(that.dateBtnValue); - }, 1000 * 60); - this.intervalId = intervalId; + }, 1000 * 60 * 5); } }