What I'm trying to do is when a user uploads some data there will be 2 buttons one is old products and the other is new products. When the user clicks either of those buttons then the products will be uploaded with either 'old_product' or 'new_product'. But when I click on either button I get this error
_this.product[value].push is not a function
Here is my code
<template>
<div>
<input type="file" class="product_upload" id="product_upload" @change="previewFiles">
<button type="button" class="btn btn-primary" @click=uploadProduct('new_product')>New Product</button>
<button type="button" class="btn btn-primary" @click=uploadProduct('old_product')>Old Product</button>
</div>
</template>
<script>
export default {
data() {
return {
product: {
old_product: [],
new_product: []
}
}
},
methods: {
previewFiles(event){
return event.target.files;
},
uploadProduct(value){
let files = this.previewFiles;
this.product[value].push(files);
}
}
}
</script>