0👍
Even though you are using Definite Assignment Assertions, and you don’t get any error, this.remaining is undefined, and you get NaN, at some point you need to assign it some value:
directly:
private remaining: number = this.calculate();
calculate() {
return (moment(this.end)
.toDate()
.getTime() -
new Date().getTime()) /
this.interval;
}
refresh() {
setInterval(() => this.remaining = this.calculate(), this.interval);
}
For some reason assign the first value directly inside setInterval not update the value. Will be interesting to kwon why :(.
- [Vuejs]-Running a prod server using express and a webpack config on heroku
- [Vuejs]-How to trigger a function when page is changed in vuejs
Source:stackexchange.com