An Attachement component for Vue.js
This component provides an simple and out-of-box experience for file attachments.
yarn add vue-attachment
or
npm i vue-attachment --save
There is an simple example on the /demo folder. HERE
Import Globally:
import Vue from 'vue'
import VueAttachment from 'vue-attachment'
Vue.use(VueAttachment)
Import as a Component:
import VueAttachment from 'vue-attachment'
...
{
components: { VueAttachment }
}
...
<template>
<form @submit.prevent="submit">
<v-attachment v-model="attachments" endpoint="/upload.php" />
</form>
</template>
<script>
export default {
data() {
return {
attachments: [
'file.pdf',
'image.jpg'
]
}
}
},
methods: {
submit() {
....
}
}
</script>
Name | Type | Required | Default | Info |
---|---|---|---|---|
value | Array | False | [] | List of files imported (v-model when binding is important) |
endpoint | String | False | upload.php | Upload Endpoint |
Name | Params | Info |
---|---|---|
success | server message | Triggered after sending file with success |
error | server message | Triggered after sending file without success |
removed | filename | Triggered when a file is remove |
input | attachments | Triggered after a change on attachments files |