Answer the question
In order to leave comments, you need to log in
How to calculate the difference between the previous value and the new value that is changed from store?
The data from the storage in the component appears like this:
computed: {
...mapGetters('currency', {
trades:'getTrades',
totalBuyQuantity:'getTradesTotalBuyQuantity',
totalSellQuantity:'getTradesTotalSellQuantity'
})
},
data: function () {
return {
id: null,
buy_difference: null,
sell_difference: null,
prevTotalBuyQuantity:null,
prevTotalSellQuantity:null
}
},
this.prevTotalBuyQuantity = this.totalBuyQuantity;
this.prevTotalSellQuantity = this.totalSellQuantity;
this.buy_difference = this.totalBuyQuantity - this.prevTotalBuyQuantity;
this.sell_difference = this.totalSellQuantity - this.prevTotalSellQuantity;
Answer the question
In order to leave comments, you need to log in
as a result, it is not the difference that is displayed, but simply the current value of the indicator
watch: {
totalBuyQuantity(newVal, oldVal) {
this.buyDiff = newVal - oldVal;
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question