Vue定时任务setInterval

mounted() {
            this.getElevatorList();
            setInterval(this.getElevatorList, 15000);

        }

在mounted()函数里边使用setInterval(),       getElevatorList()这个方法在methods里边写,在mounted钩子函数里边调用就可以,刚开始先调用一遍,加载。然后使用setInterval(),第一个参数,调用方法的时候,不加括号,第二个参数是时间。

https://www.jianshu.com/p/180957762852

猜你喜欢

转载自blog.csdn.net/meng19910117/article/details/81506085
今日推荐