vue3 中 Element-UI 默认样式修改不了解决办法

原因:
是因为在Vue文件中的style标签上有一个特殊的属性:scoped。当一个style有这个标签,它的样式就只能作用于当前的Vue组件,可以使组件的样式不相互污染。

解决办法:
样式穿透

在前面加  ::v-deep  这个
::v-deep .ant-switch::after {
  height: 21px;
  width: 21px;
}
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
修改 Element UI 表格组件的样式,可以使用自定义样式类和覆盖默认样式。以下是一些基本的步骤: 1. 在 Vue 组件引入 Element UI 表格组件。 ```javascript <template> <el-table :data="tableData"> <el-table-column prop="name" label="Name"></el-table-column> <el-table-column prop="age" label="Age"></el-table-column> <el-table-column prop="address" label="Address"></el-table-column> </el-table> </template> <script> import { ElTable, ElTableColumn } from 'element-ui'; export default { components: { ElTable, ElTableColumn, }, data() { return { tableData: [ { name: 'John Doe', age: 30, address: '123 Main St', }, // ... ], }; }, }; </script> ``` 2. 在组件定义自定义样式类。 ```css .table-wrapper { border: 1px solid #ccc; } .el-table__header { background-color: #f5f5f5; } .el-table__body { background-color: #fff; } ``` 3. 将自定义样式类应用于表格组件。 ```javascript <template> <div class="table-wrapper"> <el-table :data="tableData" class="my-table"> <el-table-column prop="name" label="Name"></el-table-column> <el-table-column prop="age" label="Age"></el-table-column> <el-table-column prop="address" label="Address"></el-table-column> </el-table> </div> </template> <style> .my-table { width: 100%; } .el-table__header { background-color: #f5f5f5; } .el-table__body { background-color: #fff; } </style> ``` 在上面的示例,我们在 `div` 元素上应用了 `.table-wrapper` 样式类,并在表格组件上应用了 `.my-table` 样式类。然后,我们覆盖了表格组件的默认样式,例如表头和表体的背景颜色。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值