File tree Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Expand file tree Collapse file tree 2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 33 defineComponent ,
44 h ,
55 nextTick ,
6- onBeforeUnmount ,
6+ onUnmounted ,
77 onMounted ,
88 ref ,
99 shallowRef ,
@@ -49,8 +49,15 @@ export const Chart = defineComponent({
4949 const chart = toRaw ( chartRef . value )
5050
5151 if ( chart ) {
52- chart . destroy ( )
53- chartRef . value = null
52+ if ( props . destroyDelay > 0 ) {
53+ setTimeout ( ( ) => {
54+ chart . destroy ( )
55+ chartRef . value = null
56+ } , props . destroyDelay )
57+ } else {
58+ chart . destroy ( )
59+ chartRef . value = null
60+ }
5461 }
5562 }
5663
@@ -60,7 +67,7 @@ export const Chart = defineComponent({
6067
6168 onMounted ( renderChart )
6269
63- onBeforeUnmount ( destroyChart )
70+ onUnmounted ( destroyChart )
6471
6572 watch (
6673 [ ( ) => props . options , ( ) => props . data ] ,
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ export const Props = {
4444 type : String as PropType < ChartType > ,
4545 required : true
4646 } ,
47+ destroyDelay : {
48+ type : Number ,
49+ default : 0 // No delay by default
50+ } ,
4751 ...CommonProps ,
4852 ...A11yProps
4953} as const
You can’t perform that action at this time.
0 commit comments