1
I need to add the two columns when one of them is changed, for example: if evaluation is changed the highest grade is in final grade, the same thing for oriented studies.
var vm = new Vue({
el: '#vue-instance',
data: {
tablenotas: [
{
avaliacao: 1,
estudos_orientados: 2,
nota_final: 3,
},
{
avaliacao: 4,
estudos_orientados: 5,
nota_final: 9,
}
]
},
methods: {
nota: function (avaliacao, estudos_orientados) {
if (avaliacao >= estudos_orientados) {
return avaliacao
}
else if (estudos_orientados > avaliacao) {
return estudos_orientados
}
}
}
})
body {
background: #20262E;
padding: 20px;
font-family: Helvetica;
}
#app {
background: #fff;
border-radius: 4px;
padding: 20px;
transition: all 0.2s;
}
li {
margin: 8px 0;
}
h2 {
font-weight: bold;
margin-bottom: 15px;
}
del {
color: rgba(0, 0, 0, 0.3);
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.16/vue.js"></script>
<div id="vue-instance">
<table>
<thead>
<th>Avaliação</th>
<th>Estudos Orientados</th>
<th>Nota Final</th>
</thead>
<tbody>
<tr v-for="item in tablenotas">
<td><input type="text" v-model="item.avaliacao"></td>
<td><input type="text" v-model="item.estudos_orientados"></td>
<td><input type="text">{{nota(item.avaliacao, item.estudos_orientados)}}</td>
</tr>
</tbody>
</table>
</div>
I also put in the jsfiddle
What you want is to add and add this value in
nota_final
? Or that the value of{{nota(item.avaliacao, item.estudos_orientados)}}
stay in the field?– NoobSaibot
@Noobsaibot I need both. Show value and change nota_end value
– Luis Souza
Okay, I left an answer. But it wouldn’t be right to display the sum of the notes ?
– NoobSaibot