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