<el-radio-group v-model="staffInfo.sex"> <el-radio-button label="1">男</el-radio-button> <el-radio-button label="2">女</el-radio-button> </el-radio-group> 样式修改 ::v-deep.el-radio-button{ margin-right: 15px; border-radius:4px; .el-radio-button__inner {//修改按钮样式 width: 120px; height: 42px; background: #F7F8FA; color:#333; border: 0 !important; } .el-radio-button__orig-radio:checked + .el-radio-button__inner {// 修改按钮激活样式 color: #fff; background-color: #f63; border-color: #f63; box-shadow: -1px 0 0 0 #f63; } ———这个完整的代码应该怎样写
时间: 2023-08-11 08:03:35 浏览: 282
完整的代码应该如下所示:
```html
<template>
<el-radio-group v-model="staffInfo.sex">
<el-radio-button label="1">男</el-radio-button>
<el-radio-button label="2">女</el-radio-button>
</el-radio-group>
</template>
<style scoped>
::v-deep .el-radio-button {
margin-right: 15px;
border-radius: 4px;
}
::v-deep .el-radio-button__inner {
width: 120px;
height: 42px;
background: #f7f8fa;
color: #333;
border: 0 !important;
}
::v-deep .el-radio-button__orig-radio:checked + .el-radio-button__inner {
color: #fff;
background-color: #f63;
border-color: #f63;
box-shadow: -1px 0 0 0 #f63;
}
</style>
```
注意,样式选择器中的 `::v-deep` 是用于穿透组件样式限制的,需要在样式选择器前加上 `scoped` 声明,以限定样式仅在当前组件内生效。
阅读全文