vue上传图片组件
来源:互联网 发布:什么是锁sql 编辑:程序博客网 时间:2024/06/05 07:07
<template> <div class='finish_room'> <div class='finish_room2'> <div v-for='(item ,index ) in imgs' class='room_img'> <img :src="item"> </div> <div class='room_add_btn'> <span>上传图片</span> <input @change='add_img' type="file"> </div> </div> </div></template><script > module.exports={ data:function(){ return{ imgs:[], } }, props:{}, methods:{ dataURLtoBlob(dataurl){ var arr = dataurl.split(','), mime = arr[0].match(/:(.*?);/)[1], bstr = atob(arr[1]), n = bstr.length, u8arr = new Uint8Array(n); while(n--){ u8arr[n] = bstr.charCodeAt(n); } return new Blob([u8arr], {type:mime}); }, add_img(event){ var reader =new FileReader(); var img1=event.target.files[0]; reader.readAsDataURL(img1); var that=this; reader.onloadend=function(){ that.imgs.push(reader.result) console.log(that.dataURLtoBlob(reader.result)); } } } }</script><style scoped > .finish_room{ width: auto; height: auto; } .finish_room2{ width: 100%; height: auto; padding-top: 15px; padding-bottom: 15px; display: flex; align-items: center; border-bottom: 2px solid #e1e1e1; } .finish_room2 .room_img{ width: 150px; height: 100px; margin-right: 10px; position: relative; overflow: hidden; } .finish_room2 .room_img img{ width: 100%; height: 100%; } .finish_room2>.room_img span{ position: absolute; width: auto; height: auto; right: 5px; bottom:3px; } .room_add_btn{ width: 80px; height: 40px; border: 1px solid #e1e1e1; position: relative; line-height: 40px; text-align: center; background: #00a6c6; color: #fff; border-radius: 4px; } .room_add_btn input{ position: absolute; top: 0px; left: 0px; width: 100%; height: 100%; z-index: 99999; opacity: 0; }</style>
阅读全文
0 0
- vue 图片上传组件
- vue上传图片组件
- vue上传图片组件编写
- vue上传图片组件编写
- Vue上传图片预览以及删除的vue组件
- vue上传图片组件(支持拖拽文件夹上传)
- require.js+vue+vue-router+vue-resource开发微信上传图片组件
- vue 上传图片
- vue上传单张图片
- vue 上传图片
- 基于Vue + Node.js + MongoDB的图片上传组件,实现图片的预览和删除
- 从0开始做一个的Vue图片/ 文件选择(上传)组件[基础向]
- 从0开始做一个的Vue图片/ 文件选择(上传)组件[基础向]
- vue移动端图片上传
- vue上传多张图片
- input_file上传图片(vue)
- 无组件上传图片
- 求图片上传组件
- c++常用函数
- Windows10下的docker安装与入门 (二)使用docker引擎在容器中运行镜像
- 网络流笔记
- React 向事件处理程序传递参数(不跳,alert)
- CP340的简要讲解
- vue上传图片组件
- java基础与提高系列-java 代理(静态代理和动态代理)
- jvisualvm插件安装的正确姿势(解决网络问题)
- Spring Boot之返回JSON数据
- Maven构建SSH项目pom文件依赖包
- MySQL数据类型和常用字段属性总结
- 软工文档感受----可行性研究报告
- OkHttpClient网络请求
- Android拨打电话