setInterval改成setTimeout
This commit is contained in:
@@ -51,19 +51,25 @@
|
||||
},
|
||||
onLoad () {
|
||||
this._getBillsCount()
|
||||
this.intervalId = setInterval(() => {
|
||||
this._getBillsCount()
|
||||
}, this.interTime)
|
||||
this.timerFun(this._getBillsCount, this.interTime)()
|
||||
},
|
||||
beforeDestroy () {
|
||||
clearInterval(this.intervalId)
|
||||
this.intervalId = null
|
||||
},
|
||||
destroyed () {
|
||||
clearInterval(this.intervalId)
|
||||
this.intervalId = null
|
||||
if (this.intervalId !== null) {
|
||||
clearTimeout(this.intervalId)
|
||||
this.intervalId = null
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
timerFun(f, time) {
|
||||
let _this = this
|
||||
return function backFun() {
|
||||
clearTimeout(_this.intervalId)
|
||||
_this.intervalId = setTimeout(function () {
|
||||
f()
|
||||
backFun()
|
||||
}, time)
|
||||
}
|
||||
},
|
||||
async _getBillsCount () {
|
||||
let res = await getBillsCount()
|
||||
if (res.code === 1) {
|
||||
|
||||
Reference in New Issue
Block a user