File tree Expand file tree Collapse file tree 2 files changed +14
-3
lines changed
Expand file tree Collapse file tree 2 files changed +14
-3
lines changed Original file line number Diff line number Diff line change 131131 </div >
132132</template >
133133<script setup lang="ts">
134- import { onMounted , ref } from ' vue' ;
134+ import { onMounted , onUnmounted , ref } from ' vue' ;
135135
136136import { getPurchaseList } from ' @/api/detail' ;
137137import { t } from ' @/locales' ;
@@ -203,8 +203,9 @@ const pagination = ref({
203203
204204const updateCurrent = ref (0 );
205205
206+ const intervalId = ref ();
206207const stepUpdate = () => {
207- setInterval (() => {
208+ intervalId . value = setInterval (() => {
208209 if (updateCurrent .value > 5 ) {
209210 updateCurrent .value = - 1 ;
210211 }
@@ -225,6 +226,12 @@ const fetchData = async () => {
225226 }
226227};
227228
229+ onUnmounted (() => {
230+ if (intervalId .value ) {
231+ clearInterval (intervalId .value );
232+ }
233+ });
234+
228235onMounted (() => {
229236 stepUpdate ();
230237 fetchData ();
Original file line number Diff line number Diff line change @@ -163,11 +163,12 @@ const visible = ref(false);
163163// monitorChart logic
164164let monitorContainer: HTMLElement ;
165165let monitorChart: echarts .ECharts ;
166+ const intervalId = ref ();
166167onMounted (() => {
167168 monitorContainer = document .getElementById (' monitorContainer' );
168169 monitorChart = echarts .init (monitorContainer );
169170 monitorChart .setOption (getSmoothLineDataSet ({ ... chartColors .value }));
170- setInterval (() => {
171+ intervalId . value = setInterval (() => {
171172 monitorChart .setOption (getSmoothLineDataSet ({ ... chartColors .value }));
172173 }, 3000 );
173174});
@@ -194,6 +195,9 @@ const updateContainer = () => {
194195};
195196
196197onUnmounted (() => {
198+ if (intervalId .value ) {
199+ clearInterval (intervalId .value );
200+ }
197201 window .removeEventListener (' resize' , updateContainer );
198202});
199203
You can’t perform that action at this time.
0 commit comments