I am creating a timer using vue.js and moment.js, I use only minutes and seconds, my code should work, but I do not get the desired result:
var app = new Vue({
el: '#app',
data: {
date: moment(60 * 10 * 1000)
},
computed: {
time: function(){
return this.date.format('mm:ss');
}
},
mounted: function(){
var aa = this.date;
setInterval(function(){
aa.subtract(1, 'seconds');
}, 1000);
}
});
<script src="https://momentjs.com/downloads/moment.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.min.js"></script>
<div id="app">{{ time }}</div>