docs_vue2/one/docs/demo/uploader/validate.vue
2020-08-13 11:47:56 +08:00

54 lines
1.2 KiB
Vue
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<template>
<article>
<section>
<veui-uploader
v-model="images"
type="image"
action="https://app.fakejson.com/q/ELymQ7xh?token=AWFkjMICPSAB_bO_z-Lnog"
accept="jpg,png"
:max-count="6"
max-size="100kb"
:validator="validator"
>
<template #desc>
请选择jpgpng图片大小不超过100kb宽高分别大于200px最多上传6张图片
</template>
</veui-uploader>
</section>
</article>
</template>
<script>
import { Uploader } from 'veui'
export default {
components: {
'veui-uploader': Uploader
},
data () {
return {
images: [
{
src: '/images/development/uploader/demo-image1.jpg'
},
{
src: '/images/development/uploader/demo-image2.jpg'
}
],
validator (file) {
return new Promise(resolve => {
let image = new Image()
image.src = window.URL.createObjectURL(file)
image.onload = () => {
resolve({
valid: image.height > 200 && image.width > 200,
message: '图片宽高太小'
})
}
})
}
}
}
}
</script>