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); } }