Answer the question
In order to leave comments, you need to log in
Why is the computed method not firing in vue?
There is a method:
parse: function () {
var vm = this;
var data = $('#form-one-ass').val();
var rows = data.split("\n");
var tmpWorkOrders = [];
for(var y in rows) {
var cells = rows[y].split("\t");
tmpWorkOrders.push({
NUMBER: cells[0],
SUM: parseFloat(cells[1]),
DATE: cells[2],
CONTRACTOR: cells[3]
});
this.form.workOrders = Object.assign([], vm.form.workOrders, tmpWorkOrders);
//this.form.workOrders = Object.assign([], this.form.workOrders, tmpWorkOrders);
};
}
sumShipping: function () {
var sum = 0;
this.form.workOrders.forEach(function (val, i) {
sum += val.SUM;
});
return sum;
}
Answer the question
In order to leave comments, you need to log in
It's not about Vue, it calculates everything normally. The fact is that in the parse method it was necessary to do a normal check for creating an array, it generated the last empty string with the NaN sum and the summation in computed did not work.
sumShipping is generally used somewhere or just declared?
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question