layui-html元素
<ul class="layui-tab-title" id="myTab"><li class="layui-this" lay-id="demo1">表格列表</li><li lay-id="demo2">数据图表</li></ul>
js代码
//Hash地址的定位**页面加载执行哪个tab**var layid = location.hash.replace(/^#demo=/, '');element.tabChange('demo', layid);if(layid == 'clubTable'){element.tabChange('demo', 'clubTable'); //切换到:Tab1setClubTable();}else if(layid == 'playerTable'){element.tabChange('demo', 'playerTable'); //切换到:Tab2setPlayerTable();}else{element.tabChange('demo', 'clubTable'); //切换到:Tab2(默认切换Tab1)setClubTable();}//**点击tab函数**element.on('tab(demo)', function(elem) {location.hash = 'demo=' + $(this).attr('lay-id');if ($(this).hasClass("layui-this") && $(this).hasClass('hasData')) {return false;}if(elem.index == 0){var index = layer.load(1, {shade: [0.1,'#fff'] });//假加载setTimeout(function(){ layer.close(index); }, 500);setClubTable();}else{var index = layer.load(1, {shade: [0.1,'#fff'] });setTimeout(function(){ layer.close(index); }, 500);setPlayerTable();}});