vue+Element Ui 实现自动上传图片

点击上传文件按钮 beforeAvatarUpload方法自动上传1到多个图片


   上传文件   

    

**//上传画稿之前先判断画稿规格 再插oracle 再post到php
//为了解决onload异步使用promise**

beforeAvatarUpload:function(file) {
    var _this = this;
    return new Promise(function(resolve, reject) { //为了解决onload异步使用promise
        if(file.name.length > 100){
            _this.$alert(file.name+'图片名称字符长度超过100,不能上传!', '提示', {confirmButtonText: '确定'});
            reject();
            return;
        }
        var reader = new FileReader();
        var img_oracleFlag = false;
        reader.onload = function(event) { //onload是异步的
            var image = new Image();
            image.onload = function () {
                var width = this.width;
                var height = this.height;
                if (width>height && vm.radio.GGH=="小牌"){
                    _this.$alert(file.name+'不能上传!', '提示', {confirmButtonText: '确定'});
                    reject();
                    return;
                }else if (width

你可能感兴趣的:(vue+Element Ui 实现自动上传图片)