0.0.6 • Published 5 years ago

vue-attachment v0.0.6

Weekly downloads
2
License
ISC
Repository
github
Last release
5 years ago

vue-attachment

An Attachement component for Vue.js

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

NameTypeRequiredDefaultInfo
valueArrayFalse[]List of files imported (v-model when binding is important)
endpointStringFalseupload.phpUpload Endpoint

Events

NameParamsInfo
successserver messageTriggered after sending file with success
errorserver messageTriggered after sending file without success
removedfilenameTriggered when a file is remove
inputattachmentsTriggered after a change on attachments files

License

MIT License