لا اعتقد المشكلة من cloudinary
اعتذر عن كتابة الاكواد لك.
file.vue
<ValidationObserver ref="observer" v-slot="{ validate, reset }" style="width:100%">
<v-flex md12>
<form>
<ValidationProvider v-slot="{ errors }" name="Image" rules="size:5000">
<v-file-input
accept="image/*"
@change="processImg($event)"
ref="myFileInput"
counter
label="Image"
placeholder="Select your image"
prepend-icon=""
append-icon="mdi-paperclip"
outlined
:show-size="1000"
:error-messages="errors"
>
<template v-slot:selection="{ text }">
<v-chip
color="primary"
dark
label
small
>
{{ text }}
</v-chip>
</template>
</v-file-input>
</ValidationProvider>
</form>
</v-flex>
</ValidationObserver>
file.js
<script>
export default {
data() {
return {
newProduct: {
img: null,
},
loadingImg: false,
}
},
computed: {
imageUpload() {
let imageURL = this.$store.getters.imageUpload;
this.newProduct.img = imageURL;
return imageURL;
}
},
methods: {
processImg(event) {
let file = event
this.loadingImg = true
this.$store.dispatch('imageUpload', file)
.then(res => {
this.loadingImg = false
})
.catch(err => {
// here i want clear input
this.newProduct.img = null
this.loadingImg = false
})
}
}
}
</script>
المشكلة في مكون vuetify في حال حدوث خطأ يبقى الملف في حقل الادخال.
اعتقد من الافضل ازالة هذا الملف عند حدوث مشكلة
حاولت استخدام
this.$refs.myFileInput.value = null
تنجح في المرة الاولى ولكنها تفشل في حال حدوث خطا للمرة الثاني, مع رسالة في الكونسل عند حدوث الخطا الاول
[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the parent component re-renders. Instead, use a data or computed property based on the prop’s value. Prop being mutated: “value”