zoukankan      html  css  js  c++  java
  • 图片上传

    //上传图片

    <el-upload action=""
    ref="uploadImg"
    :show-file-list="false"
    :auto-upload="false"
    :limit=1
    :on-change="handleAvatarSuccess">
    <img :src="dialogImageUrl"/>
    <el-button class="upload_btn">上传图片</el-button>
    </el-upload>


    handleAvatarSuccess(file) {
    let fileType = file.raw.type,
    fileSize = file.size / 1024 / 1024,
    typeFlag = false,
    sizeFlag = false;
    if (fileType === 'image/jpeg' || fileType === 'image/png') {
    typeFlag = true;
    } else {
    this.$alert('照片只能上传jpeg、png格式', '提示', {
    confirmButtonText: '确定'
    });
    this.$refs.uploadImg.clearFiles();
    }

    if (fileSize < 10) {
    sizeFlag = true;
    } else {
    this.$alert('上传头像图片大小不能超过10MB', '提示', {
    confirmButtonText: '确定'
    });
    this.$refs.uploadImg.clearFiles();
    }
    if (typeFlag && sizeFlag) {
    this.dialogImageUrl = URL.createObjectURL(file.raw);
    this.personnelFormData.append('file', file.raw);

    }
    this.$refs.uploadImg.clearFiles();//elementUI  清空搜索条件显示的错误
    }

    },

  • 相关阅读:
    java学习的第三天
    java学习的第二天
    java学习的第一天
    兼容性测试2
    兼容性测试
    安全性测试
    界面测试
    功能性测试
    简历小技巧
    day13
  • 原文地址:https://www.cnblogs.com/namehou/p/12383119.html
Copyright © 2011-2022 走看看