el-upload 限制图片上传的方法

<el-upload 
    :action="action" 
    :accept="'image/*'" 
    list-type="picture-card" 
    :file-list="filelist"
    :on-preview="handlePictureCardPreview" 
    :before-remove="beforeRemove"
    :class="{disabled:uploadDisabled}">
     <i class="el-icon-plus">i>
el-upload>

<script>
....
computed:{
// 限制只上传两张
    uploadDisabled(){
        return  this.filelist.length > 1
    }
}
....
script>
<style>
.disabled .el-upload--picture-card {
    display: none;
}
style>

你可能感兴趣的:(element,ui)