Skip to content

Upload 上传

通过点击或者拖拽上传文件

按需引入方式

如果是完整引入可跳过此步骤

javascript
import Vue from 'vue'
import { Upload } from 'element-ui'
import 'element-ui/lib/theme-chalk/base.css'
import 'element-ui/lib/theme-chalk/upload.css'
import 'element-ui/lib/theme-chalk/icon.css'

Vue.use(Upload)

拖拽上传

vue
<template>
    <el-upload
        class="upload-demo"
        drag
        action="https://jsonplaceholder.typicode.com/posts/"
        multiple
    >
        <i class="el-icon-upload"></i>
        <div class="el-upload__text">将文件拖到此处,或<em>点击上传</em></div>
        <div class="el-upload__tip" slot="tip">
            只能上传jpg/png文件,且不超过500kb
        </div>
    </el-upload>
</template>

Attributes

参数说明类型默认值
action上传的接口地址string
multiple是否支持多选文件booleanfalse
drag是否启用拖拽上传booleanfalse
...