fix: 优化页面销毁时对echarts实例的销毁
This commit is contained in:
@@ -95,6 +95,9 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -147,6 +147,9 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -567,7 +567,9 @@ export default {
|
|||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.chartOption = null
|
this.chartOption = null
|
||||||
this.unitConvert = null
|
this.unitConvert = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -456,7 +456,9 @@ export default {
|
|||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.chartOption = null
|
this.chartOption = null
|
||||||
this.unitConvert = null
|
this.unitConvert = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -734,7 +734,9 @@ export default {
|
|||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
clearTimeout(this.timerScroll)
|
clearTimeout(this.timerScroll)
|
||||||
clearTimeout(this.timerSearch)
|
clearTimeout(this.timerSearch)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.unitConvert = null
|
this.unitConvert = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -703,7 +703,9 @@ export default {
|
|||||||
if (myChart) {
|
if (myChart) {
|
||||||
echarts.dispose(myChart)
|
echarts.dispose(myChart)
|
||||||
}
|
}
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
// 检测时发现该方法占用较大内存,且未被释放
|
// 检测时发现该方法占用较大内存,且未被释放
|
||||||
this.unitConvert = null
|
this.unitConvert = null
|
||||||
myChart = null
|
myChart = null
|
||||||
|
|||||||
@@ -193,6 +193,14 @@ export default {
|
|||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
|
const dom = document.getElementById('chart1')
|
||||||
|
const dom2 = document.getElementById('chart2')
|
||||||
|
if (dom) {
|
||||||
|
echarts.dispose(dom)
|
||||||
|
}
|
||||||
|
if (dom2) {
|
||||||
|
echarts.dispose(dom2)
|
||||||
|
}
|
||||||
this.myChart = null
|
this.myChart = null
|
||||||
this.myChart2 = null
|
this.myChart2 = null
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -152,7 +152,9 @@ export default {
|
|||||||
},
|
},
|
||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.chartOption = null
|
this.chartOption = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -336,7 +336,9 @@ export default {
|
|||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.chartOption = null
|
this.chartOption = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -633,8 +633,9 @@ export default {
|
|||||||
beforeUnmount () {
|
beforeUnmount () {
|
||||||
clearTimeout(this.timer)
|
clearTimeout(this.timer)
|
||||||
window.removeEventListener('resize', this.resize)
|
window.removeEventListener('resize', this.resize)
|
||||||
this.myChart = null
|
if (this.myChart) {
|
||||||
this.myChart = null
|
echarts.dispose(this.myChart)
|
||||||
|
}
|
||||||
this.unitConvert = null
|
this.unitConvert = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user