一个需求是需要显示到内部,机器生成的代码,记录下实现方式
官方用例
模板
<el-switch
v-model="item.status"
:active-value="2"
:inactive-value="1"
active-text="启用"
inactive-text="停用"
@change="handleOpenChange(item, $event)"
/>
样式
<style lang="scss">
.template-container .action-row .switch-wrapper {
.el-switch__core {
width: 48px !important;
}
.el-switch__label * {
line-height: 1;
font-size: 9px;
display: inline-block;
}
.el-switch__label {
position: absolute;
display: none;
color: #fff !important;
font-size: 9px !important;
}
/*打开时文字位置设置*/
.el-switch__label--right {
z-index: 1;
right: 20px;
margin-left: 4px;
}
/*关闭时文字位置设置*/
.el-switch__label--left {
z-index: 1;
left: 20px;
}
/*显示文字*/
.el-switch__label.is-active {
display: block;
}
.el-switch__label.el-switch__label--left.is-active {
width: 25px !important;
margin-left: 2px !important;
color: #04091A !important;
}
}
</style>