vue3+ts使用setInterval、setTimeout方法
两种方法
const interval:NodeJS.Timer = setInterval(function () {},2000)
const interval:number = window.setInterval(function () {},2000)
如果是下面这种写法,会报错Type 'Timeout' is not assignable to type 'number'
const interval:number = setInterval(function () {})