之前花了两个月用vue做了一个建筑照片我的webApp,前端就我一人,负责用vue写页面对接接口,后台一个程序员负责写接口,嵌套个安卓ios的壳。搞的是风风火火,过程也是很心累,大多不在技术,在于所谓的产品乱改需求,其实产品也不是产品,只是一个资历尚浅的副总。看不得我们工作清闲一点,于是非得找个活。干了两个多月,中途流程走不通,各种改改改,好不容易上线了,运营两周之后就没下文了,放弃了,也是情理之中,至始至终没有人看好过这个东西,包括我们两个开发者。

不吐槽,不吐槽,过程中有个上传身份证,企业执照的功能,也就是上传图片,记录一下,以后说不定有用。

html:

<template>
<div class="personPic">
<myHeader :hTitle="hTitle" ref="myHeader" :noMore="noMore"></myHeader>
<div class="inner">
<div class="upload">
<div class="txt">
<p>点击上传</p>
<span>营业执照</span>
</div>
<img :src="front_pic" v-show="front_pic!=''">
<input type="file" @change="imgPreview($event, 1)"/>
</div>
<div class="msg">
<p>请保持姓名和身份证号信息与证件<span>信息一致!</span></p>
<p>保证所有信息<span>清晰完整</span></p>
</div>
<button class="flowBtn" @click="send">提交审核</button>
<prompt ref="prompt" :promptText="promptText"></prompt>
<loading ref="loading"></loading>
</div>
</div>
</template>
js:
data () {
return {
promptText: '',
front_pic: ''
}
},
// 上传图片
imgPreview: function (e, index) {
// 获取文件
var file = e.target.files[0]
var imageType = /^image\//
// 是否是图片
if (!imageType.test(file.type)) {
  this.promptText=‘请选择图片!’
return
}
var formData = new FormData()
formData.append('file', file)
this.$refs.loading.show()
this.$http.post(this.publicUrl + 'upload/picture', formData).then(function (response) {
this.$refs.loading.show()
if (response.data.status === -1) {
this.promptText = response.data.msg
this.$refs.prompt.show()
} else {
this.front_pic = this.publicUrl + response.data.data.url // 提交图片获取URL,返回
}
}, function () {
this.promptText = '请求失败'
this.$refs.prompt.show()
})
}
css:
.personPic{
padding-top: 1rem;
font-size: 0.3rem;
.inner{
padding: 0.8rem 0.8rem 0;
.upload{
position: relative;
width: 100%;
height: 7rem;
background:#f7f7f7 url("../../assets/images/upload.png") no-repeat 1.2rem center;
background-size: 0.7rem 0.7rem;
border-radius: 0.01rem;
margin-bottom: 0.4rem;
overflow: hidden;
p{
color: #1a4cbf;
margin-bottom: 0.1rem;
}
span{
color: #999999;
}
.txt{
text-align: center;
padding: 3.1rem 0 0 1rem;
}
input{
position: absolute;
top: 0;
width: 100%;
height: 100%;
opacity: 0;
}
img{
position: absolute;
top: 0;
width: 100%;
height: 100%;
display: block;
border-radius: 0.01rem;
}
}
.msg{
text-align: center;
line-height: 0.5rem;
font-size: 0.28rem;
p{
color: #666666;
span{
color: #fe5642;
}
}
}
}
}
 

vue图片上传的更多相关文章

  1. vue图片上传组件

    前言:很多项目中都需要用到图片上传功能,而其多处使用的要求,为了避免重复造轮子,让我决定花费一些时间去深入了解,最终封装了一个vue的图片上传组件.现将总结再次,希望有帮助. Layout <d ...

  2. vue 图片上传

    功能说明: 1.调用手机拍照功能 2.调用相册功能 3.图片上传功能 4.图片预览功能 5.图片删除功能 关键点: .input 新增multiple .accept="image/*处理I ...

  3. vue 图片上传功能

    这次做了vue页面的图片上传功能,不带裁剪功能的! 首先是html代码,在input框上添加change事件,如下:   <ul class="clearfix">   ...

  4. vue图片上传的简单组件

    <template> <div class="rili" id="rili"> <div class="updel&qu ...

  5. 保姆级SpringBoot+Vue图片上传到阿里云OSS教程

    小二是新来的实习生,作为技术 leader,我给他安排了一个非常简单的练手任务,把前端 markdown 编辑器里上传的图片保存到服务器端,结果他真的就把图片直接保存到了服务器上,这下可把我气坏了,就 ...

  6. vue图片上传到七牛云

    代码: <template> <div class="upload-info"> <div> <el-upload class=" ...

  7. vue图片上传及java存储图片(亲测可用)

    1.前言 在使用elementui的upload组件时,我一直无法做到上传的图片和其他数据一起提交.单纯的上传文件,java的存储图片的方式也有局限性. 我知道的后端保存图片有两种方式:一种是直接存储 ...

  8. 后台管理系统之“图片上传” --vue

    图片上传(基于vue) 相信上传图片是所有系统必备的功能吧,工作中的第一个管理系统就在上传图片的功能上卡顿了一整天. 当时用的elementUI组件,但是由于样式和设计图样式差别较大再加上原生相较好理 ...

  9. vue+axios实现移动端图片上传

    在利用vue做一些H5页面时,或多或少会遇到有图片上传的操作,主要是运用html5里面的input[type=file]来实现,传递到后端的数据是以二进制的格式传递,所以上传图片的请求与普通的请求稍微 ...

随机推荐

  1. 大数据入门到精通15--hive 对 date类型的处理

    一.基础日期处理 //date 日期处理select current_date;select current_timestamp;//to_date(time) ;to_date(string)sel ...

  2. Apache Flink 数据流编程模型

    抽象等级(Levels of Abstraction) Flink提供不同级别的抽象来开发流/批处理应用程序. Statefule Stream Processing: 是最低级别(底层)的抽象,只提 ...

  3. Python学习—框架篇之初识Django

    什么是web框架? 框架,即framework,特指为解决一个开放性问题而设计的具有一定约束性的支撑结构,使用框架可以帮你快速开发特定的系统,简单地说,就是你用别人搭建好的舞台来做表演. 对于所有的W ...

  4. python--第二十四天总结

    CMDB介绍 CMDB --Configuration Management Database 配置管理数据库, CMDB存储与管理企业IT架构中设备的各种配置信息,它与所有服务支持和服务交付流程都紧 ...

  5. 腾讯2019年暑期实习生招聘在线笔试技术研究和数据分析方向第二题(python)

    def printindex(n,arr): # n = int(input()) # arr = list(map(int,input().split(' '))) li1=[] li2=[] fo ...

  6. Android判断一个点是否在矩形区域内

    个人遇到的问题判断按钮的点击事件还是滑动事件 private boolean button1Down = false; private boolean button2Down = false; pri ...

  7. 20175126《Java程序设计》第七周学习总结

    # 20175126 2016-2017-2 <Java程序设计>第七周学习总结 ## 教材学习内容总结 - 本周学习方式主要为手动敲代码并理解内容学习. - 学习内容为教材第八章,本章主 ...

  8. Spring component-scan 标签的实现

    在以前文章Spring自定义标签实现中,曾说过,在sprin g 配置文件中,除了be an beans import 常用的标签意外,其他的标签都是遵循Spring 自定义标签的扩展机制进行实现功能 ...

  9. python抓取网页数据处理后可视化

    抓取文章的链接,访问量保存到本地 #coding=utf-8 import requests as req import re import urllib from bs4 import Beauti ...

  10. 一个不错的多叉树, stl风格

    tree<std::string> tr9; tree<std::string>::pre_order_iterator iter1; tr9.set_head("h ...