docs_vue2/one/docs/demo/uploader/custom.vue
Justineo 32632e796e docs: update docs
Change-Id: I76d0f72679cd75085f5ffd42f641daa198cafe11

docs: update docs for alert/autocomplete/carousel, etc.

Change-Id: Ib7507f4979024f53c127e4b64b88560b93999db7

fix: update for autocomplete filter

Change-Id: Ie54556715fa52838aeb6caaa19b4f9a9f14b490f

docs: add docs for calendar/transfer/cascader

Change-Id: I655b3cb3d25dd0649de9ae7e224e7063a40dd079

fix: add more demos for input/textarea

Change-Id: Iada527ca82643a435a4775110b332155512d62a7

docs: add docs for uploader,select,table, etc.

Change-Id: Ib034fd5cc9d9a420d4e002956ae925175783c5f3

docs: adjust formatting and punc.

docs: adjust docs for uploader, etc.

Change-Id: If06c8c1102eafce43f5802a333676fc9e62cd474

docs: add docs for nav

Change-Id: If56a653ec53f19239606128fd30cae80f8e10025

docs: improve anchor demos

Change-Id: I6ac1c08cc8905924d0062def1f8921fe1f302f15

docs: refine wording and format

docs: update docs for check-button-group desc

Change-Id: Ica7d6d0692250f0be6bd330b1ad4cc41938afd46
2021-10-25 20:10:29 +08:00

86 lines
2.0 KiB
Vue

<template>
<article>
<section>
<veui-uploader
v-model="images"
type="image"
:action="action"
:controls="controls"
request-mode="custom"
:upload="upload"
@moveright="handleMoveRight"
>
<template #desc>
点击图片浮层上的向右箭头按钮改变图片位置
</template>
</veui-uploader>
</section>
</article>
</template>
<script>
import { Uploader } from 'veui'
export default {
components: {
'veui-uploader': Uploader
},
data () {
return {
action: 'https://app.fakejson.com/q/ELymQ7xh?token=AWFkjMICPSAB_bO_z-Lnog',
images: [
{
key: 0,
src: '/images/development/uploader/demo-image1.jpg'
},
{
key: 1,
src: '/images/development/uploader/demo-image2.jpg'
}
],
controls (file, defaultControls) {
if (file.status === 'success') {
return [
{ name: 'moveright', icon: 'chevron-right', disabled: false },
...defaultControls
]
}
return defaultControls
},
upload: (file, { onload, onprogress, onerror }) => {
let xhr = new XMLHttpRequest()
file.xhr = xhr
xhr.upload.onprogress = e => onprogress(e)
xhr.onload = e => {
try {
onload(JSON.parse(xhr.responseText))
} catch (e) {
onload({ success: false, message: e })
}
}
xhr.onerror = e => onerror(e)
let formData = new FormData()
formData.append('file', file)
xhr.open('POST', this.action, true)
xhr.send(formData)
return () => {
xhr.abort()
}
}
}
},
methods: {
handleMoveRight (file, index) {
if (index < this.images.length - 1) {
let temp = { ...this.images[index] }
this.$set(this.images, index, this.images[index + 1])
this.$set(this.images, index + 1, temp)
}
}
}
}
</script>