layui的table数据渲染不显示

一般出现这个问题是因为后台返回数据与table规定格式不符合。

<table class="layui-hide" id="artManage" lay-filter="artManage"></table>
					 
<script type="text/html" id="barArt">
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>

下面是配置(很重要,配置不好数据就不会显示)
response不配置会显示接口调用成功,有返回数据,但是不渲染页面

layui.use('table', function(){
	var table = layui.table;
		  
	table.render({
		 elem: '#artManage'
		 ,url:'http://localhost:8088/api/getWebsitesMange'
		 ,title: '博客管理'
		 ,cols: [[
			  {field:'id', title:'ID', width:140, fixed: 'left', unresize: true, sort: true}
			  ,{field:'title', title:'文章标题', width:140, edit: 'text'}
			  ,{field:'author', title:'作者', width:120, edit: 'text'}
			  ,{field:'pub_time', title:'发表时间', width:180, edit: 'text', sort: true}
			  ,{field:'short_cont', title:'文章内容', width:42A0}
			  ,{fixed: 'right', title:'操作', toolbar: '#barArt',width:210}
		  ]]
		  ,page: true,
		  response:{
		      statusName:'code', //规定返回的状态码字段为code
			  statusCode:200 //规定成功的状态码味200
		  },
		  parseData:function(res){
			  return {
					"code" : res.code, //解析接口状态
					"msg" : res.msg, //解析提示文本
		    		"data" : res.data //解析数据列表
			  }
		   }
	});

版权声明:本文为qq_39905409原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。