0
I’m trying to set up a panel, and I want to take the added values of a reduce to appear in the view
Inside the budgets, there’s an array of value, and I’ve done the methods to add
methods: {
open(os) {
this.os = os.id;
this.$axios
.get(this.apiAtual +
"/Orcamento/GetOrcamentos/?" +
qs.stringify({ os: this.os }, { arrayFormat: "repeat" })
)
.then(response => {
this.readonly = $user.comercial ? false : response.data.readonly;
if(os.situacao.id >= 3){
this.readonly = true
}
this.orcamentos = response.data.orcamentos;
this.loading = false;
});
},
},
Computed: {
valor(){
const ValorTotal = this.valor
.reduce((acc, current) =>
acc + current, 0);
return ValorTotal;
console.log(ValorTotal)
}
},
data() {
return {
loading: false,
search: false,
cliente: null,
projeto: null,
situacao: null,
tipos: null,
orcamentos: [],
especialidade: null
I would like the value to appear on that tag
<div class="col-md-2 box box-primy">
<span> <p> TOTAL DE ORDEM DE SERVIÇO</p><br></span>
<span> <h1> {{ValorTotal}}</h1> </span>
</div>
The name of the computed property is called
valor
and notValorTotal
, and theconsole.log
that you have after Return is useless– Miguel
then logic is right?
– Christian Guimarães
Apparently yes, it puts
{{valor}}
instead of{{ValorTotal}}
. I didn’t test it, but that’s what I first noticed– Miguel
good, as the value, belongs to the budget property, should not be this budget.value, or when you call the budget in array you already have freedom to take your internal values?
– Christian Guimarães
As I don’t know the structure of the variable
this.valor
I can’t help you, but the mistake at first glance I saw was what I said above– Miguel