Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【优化】图片上传组件:支持格式限制、大小限制、支持自动压缩、优化限制张数 #2

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JaneYork
Copy link

@JaneYork JaneYork commented Dec 7, 2022

更改内容

  • 优化图片张数限制
  • 支持限制图片格式
  • 支持限制图片大小
  • 支持图片压缩,默认超过3M自动压缩,可自定义

用法

压缩依赖于LRZ:https://github.com/think2011/localResizeIMG

yarn add lrz
<j-image-upload v-model="form.pic" :number="1" :limitWidth='0' :limitHeight='0' :isMultiple='false' ></j-image-upload>

参数说明

number:张图限制
isMultiple:true可多选,可以ctrl+A
limitWidth\limitHeight:宽高限制,不设置或设置0则不限制图片
doCompress:true/false,默认超过3M自动压缩
acceptType:可选,限制图片类型,默认image/*
zipPercent:可选,压缩率,默认0.7

测试及预览图

已经过大量测试,单图、多图,回显。
image
image

image

致谢🙏

部分灵感参考于PUSDN - PGZ俱乐部

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant