【el-switch 开关文字描述显示在按钮上】

本文总结了el-switch组件的使用,并展示了如何将文字描述显示在开关按钮上的技巧,包括相关图示和实例代码。

前言

el-switch 使用总结


开关文字描述显示在按钮上

图示:
在这里插入图片描述
实例代码:


	// el-popover
	<el-popover
	   style="padding-right: 7px"
	   placement="bottom"
	   width="258"
	   trigger="click">
	   
		// switch 组件
		...
	    <div style="padding-top: 10px;display: flex;align-items: center;justify-content: space-between;">
	       <div style="display:flex; align-items: center;">
	       <span style="width: 8px;height: 8px;background: #FE8112;border-radius: 50%;"></span>
	       <span style="margin-left:5px;">IEP Children (In yellow color)</span>
	       </div>
	       <el-switch
	           class="defineSwitch"
	           v-model="iepShow"
	           active-color="rgb(136, 204, 136)"
	           inactive-color="rgb(224, 224, 224)"
	           :active-value=true
	           :inactive-value=false
	           active-text="on"
	           inactive-text="off">
	       </el-switch>
	   </div>
	   ...
       <el-button size="medium" slot="reference"><i class="fa fa-cog"></i>{{ $t('loc.settingType') }}</el-button>
    </el-popover>

	// el-switch 覆盖 CSS
	...
	.tableScopeSwitch .el-switch__label {
	    position: absolute;
	    display: none;
	    color: #fff;
	}
	/*打开时文字位置设置*/
	.tableScopeSwitch .el-switch__label--right {
	    z-index: 1;
	    right: 6px;    /*不同场景下可能不同,自行调整*/
	}
	/*关闭时文字位置设置*/
	.tableScopeSwitch .el-switch__label--left {
	    z-index: 1;
	    left: 6px;    /*不同场景下可能不同,自行调整*/
	}
	/*显示文字*/
	.tableScopeSwitch .el-switch__label.is-active {
	    display: block;
	}
	.tableScopeSwitch.el-switch .el-switch__core,
	.el-switch .el-switch__label {
	    width: 75px !important;    /*开关按钮的宽度大小*/
	}
	...
	
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值