Skip to content

图片上传

Demo

使用FileReader方法,选择图片后读取到base64格式的图片信息,通过赋值给imgsrc实现图片预览

vue
<template>
  <uploadImg v-model="imgurl"></uploadImg>
</template>
<script setup lang="ts">
import { ref } from 'vue'
import uploadImg from './uploadImg/uploadImg.vue'

const imgurl = ref('')
</script>

Props

参数类型说明
v-modelany图片路径或对象
maxnumber图片大小限制,默认500k
tipstring仅支持jpg,png,gif文件

Released under the MIT License.