File tree 2 files changed +15
-4
lines changed
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change 3
3
defineComponent ,
4
4
h ,
5
5
nextTick ,
6
- onBeforeUnmount ,
6
+ onUnmounted ,
7
7
onMounted ,
8
8
ref ,
9
9
shallowRef ,
@@ -49,8 +49,15 @@ export const Chart = defineComponent({
49
49
const chart = toRaw ( chartRef . value )
50
50
51
51
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
+ }
54
61
}
55
62
}
56
63
@@ -60,7 +67,7 @@ export const Chart = defineComponent({
60
67
61
68
onMounted ( renderChart )
62
69
63
- onBeforeUnmount ( destroyChart )
70
+ onUnmounted ( destroyChart )
64
71
65
72
watch (
66
73
[ ( ) => props . options , ( ) => props . data ] ,
Original file line number Diff line number Diff line change @@ -44,6 +44,10 @@ export const Props = {
44
44
type : String as PropType < ChartType > ,
45
45
required : true
46
46
} ,
47
+ destroyDelay : {
48
+ type : Number ,
49
+ default : 0 // No delay by default
50
+ } ,
47
51
...CommonProps ,
48
52
...A11yProps
49
53
} as const
You can’t perform that action at this time.
0 commit comments