import { defineComponent } from 'vue' import { OhVueIcon, addIcons } from 'oh-vue-icons' import { MdUpload } from 'oh-vue-icons/icons' import { message } from 'ant-design-vue' import upload from './upload' addIcons(MdUpload) // !清 asyncLoader 加载使用 export default defineComponent({ props: { ratio: { type: Number, default: 1 }, width: { type: Number, default: 64 }, value: { type: String, default: '' }, size: { type: Number, default: 4 } }, emits: { 'update:value': (() => true) as (val: string) => boolean }, setup(props, ctx) { let input: HTMLInputElement | null = null return () => (
(input = el as any)} onChange={(e) => { const file: File | undefined = (e.target as any).files?.[0] if (!file) return console.log(file.size, props.size) if (file.size > props.size * 1000 * 1000) { message.warn(`大小不得超过${props.size}mb`) return } upload(file, 'test').then((res) => { console.log(res) ctx.emit('update:value', res) }) }} />
{ input?.click() }} > {!props.value && }
支持上传 .png, .jpeg, .jpg, .svg
) } })