Upload 上传 以及图片不显示问题 element-ui
element
A Vue.js 2.0 UI Toolkit for Web
项目地址:https://gitcode.com/gh_mirrors/eleme/element
免费下载资源
·
<el-button v-if="sys_push_type_add"
class="filter-item"
size="small"
@click="handleCreate"
type="primary"
icon="edit">添加
</el-button>
<el-form-item label="头像" prop="icon">
<el-upload
class="avatar-uploader"
action="/admin/upload"//后台提供的地址
:show-file-list="false"
:on-success="handleAvatarSuccess"
:before-upload="beforeAvatarUpload">
<img v-if="form.icon" :src="form.icon" class="avatar">
<i v-else class="el-icon-plus avatar-uploader-icon"></i>
</el-upload>
</el-form-item>
handleCreate() {
//重点就是这里添加的时候可以直接清空整个表单,但是icon: ""一定要有,不然上传的图片就不会显示
this.form = {icon: ""};
},
handleAvatarSuccess(jsonData, field) {
this.form.icon = jsonData.filename;//图片上传成功后台返回的地址
},
beforeAvatarUpload(file) {}
GitHub 加速计划 / eleme / element
54.06 K
14.63 K
下载
A Vue.js 2.0 UI Toolkit for Web
最近提交(Master分支:2 个月前 )
c345bb45
6 个月前
a07f3a59
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update transition.md
* Update table.md
* Update table.md
* Update transition.md
* Update popover.md 7 个月前
更多推荐
已为社区贡献3条内容
所有评论(0)