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

21
src/views/index.vue

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

17
src/views/ty/index.vue

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

Loading…
Cancel
Save