ray-note/web/js/`JS` `setTimeout` 和 `clearT...

9 lines
478 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

最近学习vbenjs 发现的一个内存缓存中使用到的具体的要参考vben的cache代码这里只简单记录一下两个的使用办法
`setTimeout` 其实是用来设置延时任务的函数主要作用是在一段时间之后执行任务会返回一个id用来区分不同的任务
```ts
const timeoutId = setTimeout(() => {}, expire)
```
`clearTimeout` 用来清除使用setTimeout创建的延时任务
```typescript
clearTimeout(timeoutId)
```