<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" /> <title></title> <script src="js/mui.min.js"></script> <link href="css/mui.min.css" rel="stylesheet"/> <script type="text/javascript" charset="utf-8"> mui.init(); </script> </head> <body> <header class="mui-bar mui-bar-nav"> <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a> <h1 class="mui-title">hello</h1> </header> <div class="mui-content"> <!--有准确值得进度条--> <div style="padding: 20px;"> <div id="demo1" class="mui-progressbar"> <span></span> </div> </div> <div style="padding: 0px 20px;"> <button type="button" onClick="setPro()">展示进度条</button> </div> <!--获取滑块值--> <div class="mui-input-row mui-input-range"> <label>Range</label> <input type="range" min="0" max="100" id="rangel"> </div> <div style="padding: 20px;"> <input type="button" class="mui-btn" value="获取滑块值" onClick="getVal()"> </div> <!--滑块开关 绿色的--> <div class="mui-switch"> <div class="mui-switch-handle"></div> </div> <br> <div class="mui-switch mui-active"> <div class="mui-switch-handle"></div> </div> <br> <!--蓝色的滑块--> <div class="mui-switch mui-active mui-switch-blue"> <div class="mui-switch-handle"></div> </div> <br> <!--也可以在这个div标签里加上点击事件 onClick="get_active()"--> <div class="mui-switch mui-switch-blue" id="mySwitch"> <div class="mui-switch-handle"></div> </div> <div style="padding: 0px 20px;"> <button type="button" onClick="get_active()">获取滑块状态</button> </div> </div> </body> <script type="text/javascript"> /*有准确值得进度掉 */ function setPro(){ var obj = mui('#demo1'); var bl = 0; setInterval(function(){ obj.progressbar({progress:bl}).show(); bl += 10; },1000) } /*获取滑块值*/ function getVal(){ var rangeobj = mui('#rangel'); mui.toast(rangeobj[0].value); } /*获取滑块值*/ function get_active(){ var obj = document.getElementById('mySwitch'); if(obj.classList.contains('mui-active')){ mui.toast('on'); }else{ mui.toast('off'); } } /*监听滑块的变化*/ /* mui.plusReady(function(){}) //加上此方法必须在真机上运行才有效果*/ document.getElementById('mySwitch').addEventListener('toggle',function(e){ if(e.detail.isActive){ mui.toast('on'); }else{ mui.toast('off'); } }) </script> </html>