vue3 <el-form-item <el-input 组合在一起的时候,去除掉<el-form-item的边框
时间: 2023-06-10 16:08:47 浏览: 182
可以通过以下两种方式去除`<el-form-item>`的边框:
1. 使用`slot-scope`自定义表单项的渲染方式,将`<el-input>`放在`<el-form-item>`的内部,然后设置`<el-form-item>`的`border:none`样式。
```
<template>
<el-form>
<el-form-item :label="label" :prop="prop" border:none>
<template v-slot="{label, error}">
<el-input :placeholder="label"></el-input>
<div class="el-form-item__error">{{error}}</div>
</template>
</el-form-item>
</el-form>
</template>
```
2. 使用 CSS 样式覆盖掉`<el-form-item>`的默认边框样式。
```
<template>
<el-form>
<el-form-item :label="label" :prop="prop" class="no-border">
<el-input :placeholder="label"></el-input>
</el-form-item>
</el-form>
</template>
<style>
.no-border .el-form-item__content {
border: none;
}
</style>
```
以上两种方式均可以去除`<el-form-item>`的边框。建议使用第一种方式,因为它更加灵活,可以自定义表单项的渲染方式。
阅读全文
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)
![-](https://img-home.csdnimg.cn/images/20241226111658.png)