File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 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'
2222Page ({
2323  behaviors:  [TimerBehavior],
2424  onReady () {
25-     this .$setTimeout (() =>  {
25+     const   timer1   =   this .$setTimeout (() =>  {
2626      console .log (' setTimeout' 
2727    })
28-     this .$setInterval (() =>  {
29-       console .log (' setTimeout' 
28+     this .$clearTimeout (timer1)
29+ 
30+     const  timer2  =  this .$setInterval (() =>  {
31+       console .log (' setInterval' 
3032    })
33+     this .$clearInterval (timer2)
3134  }
3235})
3336
3437//  在组件中使用
3538Components ({
3639  behaviors:  [TimerBehavior],
3740  ready () {
38-     this .$setTimeout (() =>  {
41+     const   timer1   =   this .$setTimeout (() =>  {
3942      console .log (' setTimeout' 
4043    })
41-     this .$setInterval (() =>  {
42-       console .log (' setTimeout' 
44+     this .$clearTimeout (timer1)
45+ 
46+     const  timer2  =  this .$setInterval (() =>  {
47+       console .log (' setInterval' 
4348    })
49+     this .$clearInterval (timer2)
4450  }
4551})
4652``` 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments