• Vue中文件上传


     使用饿了么组件进行文件上传代码的编写时,发现里面的demo都是直接上传,并没有先传到本页面,再点击按钮发送到指定服务器的例子

    另外,如果直接使用样例的话,会很明显的发现,图片上传后,显示的缩略图会异常的慢!

    所以打算自己编写,但是这样一来,就发现了问题,貌似无法拿到file对象

    后来通过查找资料,发现了el-button的:on-change属性。

    通过给:on-change属性指定事件,我们可以实现对上传的文件的操作

    <el-upload
    class="avatar-uploader"
    action="https://jsonplaceholder.typicode.com/posts/"
    :show-file-list="false"
    :on-change="test"
    :on-success="handleAvatarSuccess"
    :before-upload="beforeAvatarUpload">
    <img v-if="imageUrl" :src="imageUrl" class="avatar">
    <i v-else class="el-icon-plus avatar-uploader-icon"></i>
    </el-upload>
    金麟岂是池中物,一遇风云便化龙!
  • 相关阅读:
    SSM环境搭建
    spring 开发 Tars
    Tars --- Hello World
    Java IO流
    Java集合
    常用类
    Pwn With longjmp
    格式化字符串漏洞利用实战之 njctf-decoder
    一步一步 Pwn RouterOS之ctf题练手
    srop实战
  • 原文地址:https://www.cnblogs.com/ABKing/p/12444203.html
Copyright © 2020-2023  润新知