html
<div>{{gradeValue}}div>
js
data () {
return {
gradeValue: '50'
}
},
created () {
this.afterSuccess('100')
},
methods: {
afterSuccess (value) {
let that = this
let current = 0
let start = Number(that.gradeValue)
let step = parseInt((value - that.gradeValue) / 80)
step = step < 1 ? 1 : step
let t = setInterval(() => {
if (value - that.gradeValue > 0) {
start += step
if (start >= value) {
start = value
clearInterval(t)
}
}
current = start
that.gradeValue = current.toString()
}, 10)
}
}
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31