Skip to content

namadnuno/vue-attachment

Repository files navigation

vue-attachment

An Attachement component for Vue.js

Preview

Version Downloads License

This component provides an simple and out-of-box experience for file attachments.

Installation

yarn add vue-attachment

or

npm i vue-attachment --save

Demo

There is an simple example on the /demo folder. HERE

Usage

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 }
}
...

Example

<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>

Properties

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

Events

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

License

MIT License