I have a select input that it has a function, I'd like to do when it changes it empty the array:
My HTML code:
<select class="form-control" id="exampleFormControlSelect1"
v-model="form.type_id"
v-on:change="getType"
>
<option :value="null">-Seleccionar-</option>
<option :value="1">Entrada</option>
<option :value="2">Salida</option>
</select>
How you can see it has a function getType, and my vuejs code:
export default {
data: function() {
return {
entrance_inputs: [{
product: null,
quantity: 0,
cost: 0
}],
k: 0,
}
},
methods: {
addEntranceProduct () {
this.entrance_inputs.push({
product: null,
quantity: 0,
cost: 0
})
console.log(this.inputs)
},
removeEntranceProduct (index) {
this.entrance_inputs.splice(index, 1)
},
getType() {
this.type_id_value = this.form.type_id;
entrance_inputs.splice(0);
}
},
computed: {
isDisabled() {
return true;
}
}
}
I have an array entrance_inputs that I add elements how you can see in addEntranceProduct, BUT in getType function I'd like to add something that it clears the entire array and it removes all elements from it, how could I do it? Thanks
this.entrance_inputs = []this.entrance_inputs.length = 0