1. 程式人生 > >vue 使用定時器setInterval

vue 使用定時器setInterval

cti fun mount bottom thp tps num math tom

來自:https://www.jianshu.com/p/180957762852 侵刪

beforeMount() {
//車輛進出設置定時器,每3秒刷新一次 var self = this; clearInterval(timer); let timer = setInterval(_getCarPeopleStreamByEntraceBottom, 3000) function _getCarPeopleStreamByEntraceBottom() { //生成隨機數用來測試 let totelNumber = new Array(8);
for (let i = 0; i < totelNumber.length; i++) { totelNumber[i] = Math.ceil(Math.random() * 10) - 1 }; let data = { carInNumber: totelNumber[0], carOutNumber: totelNumber[1] }; self.southPassagewayData = data; } _getCarPeopleStreamByEntraceBottom(); },

vue 使用定時器setInterval