Browse Source

切换页面清除定时器

lite
luyisha 3 years ago
parent
commit
90ec4165f5
  1. 26
      src/views/cultrue/index.vue
  2. 21
      src/views/index.vue
  3. 17
      src/views/ty/index.vue

26
src/views/cultrue/index.vue

@ -112,6 +112,9 @@ export default {
newreader:0,//
returncount:0,
servcount:0,
timer1: null,
timer2: null,
timer3: null
};
},
mounted() {
@ -336,7 +339,7 @@ export default {
setTimeout(() => {
var myChart = echarts.init(chartDom);
option && myChart.setOption(option);
setInterval(function () {
that.timer1 = setInterval(function () {
myChart.clear();
option && myChart.setOption(option);
run(myChart);
@ -346,17 +349,18 @@ export default {
//
cultrue_bar2() {
let that = this;
var chartDom = document.getElementById("pcgchart");
var option
var xData = this.rsqsXData;
var name = this.rsqsDataName;
// console.log(this.rsqsDataName, 'this.rsqsDataName')
var xData = that.rsqsXData;
var name = that.rsqsDataName;
// console.log(that.rsqsDataName, 'that.rsqsDataName')
// = ['', '', ''];
var data = this.rsqsDataAll;
var data = that.rsqsDataAll;
var color = ['#FF99CC', '#6666FF', '#FF6600', '#7049f0', '#fa704d', '#01babc',]
let iconData = [];
this.rsqsDataName.forEach((item, index)=>{
that.rsqsDataName.forEach((item, index)=>{
if(index==0){
iconData.push({icon: 'image://img/tyc_icon.png', name: name[0]})
}else if(index==1){
@ -520,7 +524,7 @@ export default {
setTimeout(() => {
var myChart = echarts.init(chartDom);
option && myChart.setOption(option);
setInterval(function () {
that.timer2 = setInterval(function () {
myChart.clear();
option && myChart.setOption(option);
run(myChart);
@ -804,7 +808,7 @@ export default {
setTimeout(() => {
var myChart = echarts.init(chartDom);
run(myChart);
setInterval(function () {
that.timer3 = setInterval(function () {
myChart.clear();
that.getLibraryData();
run(myChart);
@ -934,6 +938,12 @@ export default {
});
},
},
beforeDestroy(){
console.log('清除文化定时器')
clearInterval(this.timer1);
clearInterval(this.timer2);
clearInterval(this.timer3);
}
};
</script>
<style>

21
src/views/index.vue

@ -178,9 +178,11 @@ export default {
proportionData: [],
proportionData_z: [],
groupNameData: [],
timer0: null,//
timer1: null,//
timer2: null,//
timer0: null,//
timer3: null,
timer4: null,
};
},
//
@ -212,8 +214,9 @@ export default {
},
methods: {
autoTimer0(){
clearInterval(this.timer0);
this.timer0 = setInterval(() => {
let that = this;
clearInterval(that.timer0);
that.timer0 = setInterval(() => {
if(this.klselt == 'y'){
this.klselt = 'm';
}else if(this.klselt == 'm'){
@ -667,7 +670,7 @@ export default {
setTimeout(()=>{
var myChart = echarts.init(chartDom);
run(myChart);
setInterval(function () {
that.timer3 = setInterval(function () {
myChart.clear();
run(myChart);
}, 3000);
@ -909,7 +912,7 @@ export default {
var pieDom1 = document.getElementById("indexPie1");
var myChart = echarts.init(pieDom1);
run(myChart);
setInterval(function () {
that.timer4 = setInterval(function () {
myChart.clear();
that.getPieData();
run(myChart);
@ -917,6 +920,14 @@ export default {
}, 200)
},
},
beforeDestroy(){
console.log('清除总览定时器')
clearInterval(this.timer0);
clearInterval(this.timer1);
clearInterval(this.timer2);
clearInterval(this.timer3);
clearInterval(this.timer4);
}
};
</script>
<style scoped>

17
src/views/ty/index.vue

@ -206,7 +206,10 @@ export default {
oWebControl1: '',
oWebControl2: '',
videoData: [],
rightTab: 1
rightTab: 1,
timer1: null,
timer2: null,
timer3: null
};
},
@ -433,7 +436,7 @@ export default {
setTimeout(()=>{
var myChart = echarts.init(this.$refs.dinschart);
option && myChart.setOption(option);
setInterval(function () {
that.timer1 = setInterval(function () {
myChart.clear();
option && myChart.setOption(option);
run(myChart);
@ -689,7 +692,7 @@ export default {
setTimeout(()=>{
var myChart = echarts.init(chartDom);
option && myChart.setOption(option);
setInterval(function () {
that.timer2 = setInterval(function () {
myChart.clear();
option && myChart.setOption(option);
run(myChart);
@ -721,7 +724,7 @@ export default {
}, 1500);
}
run();
setInterval(function () {
that.timer3 = setInterval(function () {
run();
}, 3000);
},
@ -994,6 +997,12 @@ export default {
},
},
beforeDestroy(){
console.log('清除体育定时器')
clearInterval(this.timer1);
clearInterval(this.timer2);
clearInterval(this.timer3);
}
};
</script>
<style>

Loading…
Cancel
Save