当前位置:网站首页>a-upload上传图片
a-upload上传图片
2022-08-11 10:43:00 【Mr.Meng_95】
a-upload上传图片
<a-upload
list-type="picture-card"
:file-list="fileList"
:beforeUpload="beforeUploadMains"
@change="handleChangeImg"
:showUploadList="{
showPreviewIcon: false
}"
>
<div v-if="fileList.length < 2">
// 确定上传图片数量
<a-icon type="plus" />
</div>
</a-upload>
fileList: [],
beforeUploadMains(file, e) {
let isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'|| file.type === 'image/jpg';
if (!isJpgOrPng) {
this.$message.error('格式错误,只能上传jpg、jpeg、png');
return reject(false);
}
return false; // 阻止upload默认上传事件
},
handleChangeImg({
fileList }) {
this.fileList = fileList;
console.log(this.fileList);
},
效果

按钮上传
<a-upload
list-type="picture"
:fileList="fileList"
:beforeUpload="beforeUploadMains"
@change="handleChange"
>
<a-button type="primary" @click="addmsg">新增</a-button>
</a-upload>
fileList: [],
beforeUploadMains(file, e) {
let isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png'|| file.type === 'image/jpg';
if (!isJpgOrPng) {
this.$message.error('格式错误,只能上传jpg、jpeg、png');
return reject(false);
}
return false; // 阻止upload默认上传事件
},
handleChange(info) {
// 上传图片api
console.log(info);
},
边栏推荐
猜你喜欢

Cholesterol-PEG-FITC, Fluorescein-PEG-CLS, Cholesterol-PEG-Fluorescein water-soluble

Neuropathic pain classification picture Daquan, neuropathic pain classification

I got the P8 "top" distributed architecture manual that went viral on Ali's intranet

中小企业如何实施MES管理系统

【Prometheus】 Grafana数据与可视化

Qihua stores the future and interprets the origin of distributed

『独家』互联网 BAT 大厂 Android高级工程师面试题:174道题目让你做到面试无忧

【Prometheus】Alertmanager告警全方位讲解

Simple implementation of a high-performance clone of Redis using .NET (seven-end)
![Use Function Compute to package and download OSS files [Encounter Pit Collection]](/img/07/b5f9dc7272e12dbd07d559e79157f9.png)
Use Function Compute to package and download OSS files [Encounter Pit Collection]
随机推荐
【无标题】(完美解决)uni-app 小程序下拉刷新后刷新图标无法正常恢复的问题
当科学家决定搞点“花里胡哨”的东西
你觉得程序员是一个需要天赋的职业吗?
AcWing 273. 分级(线性DP+结论)
二、第二章变量
本地开发好的 SAP UI5 应用部署到 ABAP 服务器时,中文字符变成乱码的原因分析和解决方案
天花板级微服务大佬总结出这份451页笔记告诉你微服务就该这么学
php将form表单内容提交到数据库后中文变成??(问号)
大疆2022秋招笔试 —— 最小时间差、数组的最小偏移量
MySQL表sql语句增删查改_增加
[Ext JS]11.14 SimXhr.js?_dc=1659315492151:65 Uncaught TypeError problem analysis and solution
Qihua stores the future and interprets the origin of distributed
数据库内核面试中我不会的问题(4)
爆料!前华为微服务专家纯手打500页落地架构实战笔记,已开源
发布静态资源
SDS Observatory
4. 继承
使用.NET简单实现一个Redis的高性能克隆版(七-完结)
chrome设置为深色模式(包括整个网页)
宝塔一键部署WordPress(含宝塔添加站点、阿里云安全组配置、阿里云子域名解析)