mui switch 开关js控制打开 & Cannot read property 'toggle' of null

//打开开关

mui('#mySwitch').switch().toggle();

//小开关打开异常的情况解决办法
$(".mui-switch-handle").attr("style","");

发生Cannot read property 'toggle' of null是因为,执行打开开关需要等页面加载完在执行

写个定时器就可以了

setTimeout(function(){

  mui('#mySwitch').switch().toggle();

  //小开关打开异常的情况解决办法
  $(".mui-switch-handle").attr("style","");

},160);
原文地址:https://www.cnblogs.com/richard-ju/p/L2018005.html