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);

 

posted @ 2018-05-15 14:53  六界神话  阅读(1472)  评论(0编辑  收藏  举报