开发中经常也会遇到附件的上传和回显,最方便的就是我们封装一个公共组件在页面中引用
1、上传
在src里面新建一个文件夹
<template>
<el-upload class="upload-demo"
multiple
:limit="limit"
:accept="accept"
:headers="headers"
:file-list="fileList"
:action="uploadImgUrl"
:on-exceed="handleExceed"
:on-remove="handleRemove"
:on-success="handleSuccess"
:before-upload="beforeUpload"
:on-error="handleUploadError">
<!-- :on-preview="handlePreview" -->
<el-button size="small"
type="primary">点击上传</el-button>
<div slot="tip"
class="el-upload__tip"
style="color:#909399">
支持上传{
{ accept === "*" ? "所有" : accept }}文件,且不超过20MB,附件名称不能超过50字
</div>
</el-upload>
</template>
<script>
import { getToken } from '@/utils/auth'
export default {
components: {},
props: {
value: {
type: String,
default: null
},
accept: {
type: String,
default: '*'