mui js控制开关状态、修改switch开关的值

    xiaoxiao2021-03-25  39

    修改开关的值

      .mui-switch:before{     font-size: 13px;     position: absolute;     top: 3px;     right: 11px;     content: attr(data-off);     text-transform: uppercase;     color: #999;    }    .mui-switch.mui-active:before{     right: auto;     left: 15px;     content: attr(data-on);     color: #fff;    }

    <div class="mui-content"> <ul class="mui-table-view"> <li class="mui-table-view-cell"> <span>报警消息设置</span> <div class="mui-switch mui-active" id="mySwitch" data-off="关" data-on = "开"> <div class="mui-switch-handle"></div> </div> </li> </ul> </div>

    控制开关状态:

    document.getElementById("mySwitch").addEventListener("toggle",function(event){  if(event.detail.isActive){    var btnArray = ['取消', '确认']; mui.confirm('关闭报警推送消息后,系统将不再推送报警消息?', '警告!', btnArray, function(e) { if(e.index==1){ console.log("你关闭了报警推送"); }else{ mui("#mySwitch").switch().toggle(); } },'div') }else{     } })

    转载请注明原文地址: https://ju.6miu.com/read-50109.html

    最新回复(0)