怎么改变el-upload-list el-upload-list--text的css样式
时间: 2023-11-17 08:56:40 浏览: 291
vue2.0 使用element-ui里的upload组件实现图片预览效果方法
可以通过以下方式修改el-upload-list el-upload-list--text的css样式:
1. 使用scoped样式,将样式限制在组件内部,避免影响到其他组件。
```html
<template>
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
multiple
list-type="text"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
</template>
<style scoped>
.el-upload-list--text .el-upload-list__item-actions {
display: none;
}
</style>
```
2. 使用/deep/或>>>穿透选择器,修改组件内部的样式。
```html
<template>
<el-upload
class="upload-demo"
action="https://jsonplaceholder.typicode.com/posts/"
:on-preview="handlePreview"
:on-remove="handleRemove"
:before-remove="beforeRemove"
multiple
list-type="text"
:file-list="fileList">
<el-button size="small" type="primary">点击上传</el-button>
<div slot="tip" class="el-upload__tip">只能上传jpg/png文件,且不超过500kb</div>
</el-upload>
</template>
<style>
/deep/ .el-upload-list--text .el-upload-list__item-actions {
display: none;
}
</style>
```
阅读全文