Vue Avatar Cropper
:girl: A simple and elegant avatar cropping and upload plugin.
Installing
$ npm i ecross-avatar --save-dev
Usage
Update avatar
Properties
Property Name | Type | Description |
---|---|---|
trigger |
String|Element | The element to trigger avatar pick |
upload-url |
String | Url of upload croppped image |
upload-form-name |
Object | Form name of upload request, default: 'file' |
upload-form-data |
Object | Additional form data, default: '{}' |
upload-handler |
Function | Handler to replace default upload handler |
upload-headers |
Object | Headers of upload request, default: {} |
mimes |
String | Allowed image formats, default: image/png, image/gif, image/jpeg, image/bmp, image/x-icon |
labels |
Object | Label for buttons, default: { submit: "提交", cancel: "取消"} |
Events
-
uploading
before submit upload request, params:form
object, FormData instance.xhr
object, XMLHttpRequest instance.
-
uploaded
after request has finished, params:response
object, json parsed fromxhr.responseText
form
object, FormData instance.xhr
object, XMLHttpRequest instance.
You can listen these events like this:
... methods: ... { form } { // update user avatar attribute } ... ...
License
MIT