Upload add paste prop
This commit is contained in:
parent
24c1024502
commit
929d491534
2 changed files with 19 additions and 167 deletions
|
@ -4,6 +4,7 @@
|
|||
:class="classes"
|
||||
@click="handleClick"
|
||||
@drop.prevent="onDrop"
|
||||
@paste="handlePaste"
|
||||
@dragover.prevent="dragOver = true"
|
||||
@dragleave.prevent="dragOver = false">
|
||||
<input
|
||||
|
@ -132,6 +133,10 @@
|
|||
default() {
|
||||
return [];
|
||||
}
|
||||
},
|
||||
paste: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
}
|
||||
},
|
||||
data () {
|
||||
|
@ -172,6 +177,11 @@
|
|||
this.dragOver = false;
|
||||
this.uploadFiles(e.dataTransfer.files);
|
||||
},
|
||||
handlePaste (e) {
|
||||
if (this.paste) {
|
||||
this.uploadFiles(e.clipboardData.files);
|
||||
}
|
||||
},
|
||||
uploadFiles (files) {
|
||||
let postFiles = Array.prototype.slice.call(files);
|
||||
if (!this.multiple) postFiles = postFiles.slice(0, 1);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue