Skip to content

Commit 7f388aa

Browse files
committed
doc: 完善文档
1 parent 74a9657 commit 7f388aa

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

README.md

+12-6
Original file line numberDiff line numberDiff line change
@@ -22,25 +22,31 @@ import { TimerBehavior } from 'timer-miniprogram'
2222
Page({
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
// 在组件中使用
3538
Components({
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
```

0 commit comments

Comments
 (0)