I created a Vue component for the imageUpload component and passed the property as v-model
<image-upload v-model="form.image"></image-upload>
and inside the imgeUpload component I have this code
<input type="file" accept="images/*" class="file-input" @change="upload">
upload:(e)=>{ const files = e.target.files; if(files && files.length > 0){ console.log(files[0]) this.$emit('input',files[0]) } }
and i got
Uncaught TypeError: _this. $ emit is not a function
thanks
vuejs2 vue-component
Barakat Turki
source share