Vue.js 有没有办法检测倒计时的持续时间是否以MomentJS结束

Vue.js 有没有办法检测倒计时的持续时间是否以MomentJS结束,vue.js,momentjs,countdown,Vue.js,Momentjs,Countdown,我在VueJS和MomentJS中使用diff和duration方法从Moment开始倒计时。 我想检测持续时间何时为0,以便清除1s的间隔 有办法吗?这是我当前代码中的某个部分,其中有setInterval mounted: function () { this.date = this.$moment(this.date).utcOffset('-0300') this.difference = this.date.diff(this.today) this.durat

我在VueJS和MomentJS中使用diff和duration方法从Moment开始倒计时。 我想检测持续时间何时为0,以便清除1s的间隔

有办法吗?这是我当前代码中的某个部分,其中有setInterval

mounted: function () {
    this.date = this.$moment(this.date).utcOffset('-0300')
    this.difference = this.date.diff(this.today)
    this.duration = this.$moment.duration(this.difference)

    var timer = setInterval(function () {
        this.duration = this.duration.subtract(1, 'seconds')

        if (/* validation if duration has ended */) {
            clearInterval(timer)
        }
    }.bind(this), 1000)
我知道我可以验证每天()、小时()、分钟()和秒()是否等于0,但这样做感觉很脏,我想知道是否有更好的方法来验证这一点

另外,MomentJS月不是从指数0开始,所以从0到11吗?现在是从1点到12点。我不明白为什么

任何帮助都将不胜感激