标签:data jpg sel bsp for ant new list back
原上传默认会请求一个url,就算不填action也会请求首页,不合逻辑
使用beforeUpload属性
<Upload key="upload" beforeUpload={beforeUpload} className={styles.upload} accept=".png, .jpg, .jpeg, .bmp, mp4" listType="picture-card" showUploadList={false} ></Upload>;
return false阻止默认事件,自己取出base64进行操作
//上传资源事件重写 const beforeUpload = (file) => { getBase64(file, (imageUrl) => { setloadimg(imageUrl); onSelectUploadImage(imageUrl); }); return false; }; //取图片base64 const getBase64 = (img, callback) => { const reader = new FileReader(); reader.addEventListener(‘load‘, () => callback(reader.result)); reader.readAsDataURL(img); };
标签:data jpg sel bsp for ant new list back
原文地址:https://www.cnblogs.com/wuhairui/p/14048152.html