关于layui list的用法

function optionTab() {
		layui.use(
					[ 'form', 'layer','element','table'],
					function() {
						var $ = layui.jquery, 
						layer = layui.layer;
						var element = layui.element;
						var form = layui.form;
						table = layui.table;
						var active = {
						add:function(){
							 window.location.href=_ctx + "/route/tp?p=/fuadd";
						},
							search:function(){
							 searchMsgData(dataTable);
						},
					}
						//展示已知数据
						dataTable = table.render({
						    elem: '#data-table',
						    url:queryurl,
						    method:'post',
//						    height: 'auto',
						    height: defhig,
						    cols: [[ //标题栏
						    //  {checkbox: false, LAY_CHECKED: true}, //默认全选, sort: true
						      //{field: 'id', title: 'id', width: 180},
						     	    {title: '操作', align:'center', toolbar: '#toolbar'},
						     	    {field:'dataValue',title:'文章类型',templet: '#msgType'},
						     	   {field:'isHot',title:'是否热门',templet: '#isHot'},
						     	  {field:'isLivePlay',title:'是否直播',templet: '#isLivePlay'},
						            {field: 'title', title: '标题'},
								    {field: 'iconImgUrl', title: '封面图',templet: '#imagehead'},
								    {field: 'seeNumber', width: 180,title: '查看数量'},
								    {field: 'createDate', title: '创建时间',templet: '#tepCreateDate'}
							
						    ]],	  
						    skin: 'row', //表格风格
						    even: true,
						    page: true, //是否显示分页
						    limits: [10, 20, 30],
						    limit:10, //每页默认显示的数量
						    loading: true, 
						    even: true,
						  });
						
						$('.site-demo-button .layui-btn').on('click',function() {
									var othis = $(this), method = othis.data('method');
									active[method] ? active[method].call(this,othis) : '';
						});
					
						//监听工具条
						table.on('tool(tool)', function(obj){ 
							var id = obj.data.id;
							if(obj.event === 'edit'){
								window.location.href=_ctx + "/route/tp?p=/fuedit&id="+id;
							    } else if(obj.event === 'del'){
							    	del(id);
							    
							    } 
							});
						});
		
     }

	


你可能感兴趣的:(JavaScript)