File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -22,25 +22,31 @@ import { TimerBehavior } from 'timer-miniprogram'
22
22
Page ({
23
23
behaviors: [TimerBehavior],
24
24
onReady () {
25
- this .$setTimeout (() => {
25
+ const timer1 = this .$setTimeout (() => {
26
26
console .log (' setTimeout' )
27
27
})
28
- this .$setInterval (() => {
29
- console .log (' setTimeout' )
28
+ this .$clearTimeout (timer1)
29
+
30
+ const timer2 = this .$setInterval (() => {
31
+ console .log (' setInterval' )
30
32
})
33
+ this .$clearInterval (timer2)
31
34
}
32
35
})
33
36
34
37
// 在组件中使用
35
38
Components ({
36
39
behaviors: [TimerBehavior],
37
40
ready () {
38
- this .$setTimeout (() => {
41
+ const timer1 = this .$setTimeout (() => {
39
42
console .log (' setTimeout' )
40
43
})
41
- this .$setInterval (() => {
42
- console .log (' setTimeout' )
44
+ this .$clearTimeout (timer1)
45
+
46
+ const timer2 = this .$setInterval (() => {
47
+ console .log (' setInterval' )
43
48
})
49
+ this .$clearInterval (timer2)
44
50
}
45
51
})
46
52
```
You can’t perform that action at this time.
0 commit comments