渲染mCustomScrollbar滚动条 需要显隐切换时,先销毁再创建滚动条
if($(".patrol-list-content").parents('.mCustomScrollbar').length){
$(".patrol-list-content").parents('.mCustomScrollbar').mCustomScrollbar("destroy");
}
$(".patrol-list-content").parent().mCustomScrollbar(
{ axis:"y" // 垂直滚动条都有
axis:"yx" // 垂直水平滚动条都有
axis:"x" // 水平滚动条都有
});
}
生成html代码之前:
$(".main_body_con").mCustomScrollbar("destroy");
html添加到页面之后:
$(".main_body_con").mCustomScrollbar();
例如:
var html = '<div></div>';
$(".main_body_con").mCustomScrollbar("destroy");
$('body').append(html);
$(".main_body_con").mCustomScrollbar();