I have Vue.ja app and I try to change a value inside an object. Basically when @change="onfilechangev" occurred I would like to update name: ' ' value Is there any way to do this or as it is an object I wont be able to update it?
app.js
var vm = new Vue({
el: '#regapp',
data: {
team:[
{
img: '',
name: '',
}
],
},
methods: {
onfilechangev(event) {
let uploads = event.target.files[0]
let pic = uploads.name;
Vue.set(vm.team.name, 'pic', )
},
Thanks for the answers. I have tried to do it but no luck. I have modified the codesandbox below to my situation. https://codesandbox.io/s/736nqq6070 little explain: I have dynamically added fields with optional profile image upload. So when I have added for example 3 team members then I would like to save them to the database with Laravel on the backend. if i select an image i push that file to the selectedFile array (it works), But as the profile pic only optional and not required somehow i need to know if teamemeber has image or not. That is why I try to set a hidden input field filename. so on the back end i can check selectedField array contains the filename if yes then i can save the image to the member.
@changebinding. It is$event, notevent. Use@change="onfilechangev($event, index)"and it should work.