Vue Component Multiple Image Upload
Welcome
Hello Everyone,My name is Zin Min Htet and here is my Facebook account.
Now, I will show you how to Upload Multiple Image using vue-component.
There is also an image Preview & Remove method.
I hope this can help you a lot with your website.
Installation
npm i vue-multi-image-upload-mm
Setup
1 - In your script tag import the vue component
<script>
import VueMultiImageUpload from 'vue-multi-image-upload-mm';
export default {
components:{
VueMultiImageUpload
}
}
</script>
2 - In your Vue Template
<template>
<vue-multi-image-upload @data-image="images" :max="4" :data-reset="component"/>
</template>
How it works
1.Images methods can listen child input data from parent component.
2.We can also limit the number of images upload to maximun , :max="limitNumber".
3.If you want to reset child componet data,You can use :data-reset props to passing Object
⇃⇃⇃⇃⇂⇂⇂⇂
<script>
export default {
data(){
return {
component : {}
}
},
methods:{
images(e){
e.map(res=>console.log(res))
},
clear(){
this.component.clear = true;
}
}
}
</script>
Usage
That's all what you need
<template>
<vue-multi-image-upload @data-image="images" :max="4" :data-reset="component" :options="options"/>
<button @click="component.clear = true">Clear</button>
</template>
<script>
import VueMultiImageUpload from 'vue-multi-image-upload-mm';
export default {
data(){
return {
component : {},
options : {
max:'Limit',
select:'Choosed',
ready:'Ready'
}
}
},
components:{
VueMultiImageUpload
},
methods:{
images(e){
let images = [];
e.map(res=> images.push(res));
console.log(images);
}
}
}
</script>