<el-switch
    :value="true"
    active-color="#2b73bb"
    inactive-color="#DCDFE6"
    class="switchStyle"
    :active-value="true"
    :inactive-value="false"
    active-text="开"
    inactive-text="关">
</el-switch>

 样式:

<style lang="scss" scoped>

::v-deep .el-switch__label {
  position: absolute;
  display: none;
  color: #fff;
}
/*打开时文字位置设置*/
::v-deep .el-switch__label--right {
  z-index: 1;
  right: 20px;
}
/*关闭时文字位置设置*/
::v-deep .el-switch__label--left {
  z-index: 1;
  left: 20px;
}
/*显示文字*/
::v-deep .el-switch__label.is-active {
  display: block;
}
::v-deep .el-switch .el-switch__core,
.el-switch .el-switch__label {
  width: 55px;
}
</style>

Logo

前往低代码交流专区

更多推荐