后台返回的数据格式:
layui的数据表格接口只能获取到data属性的最外层数据,我们项目中返回的JSON数据branchInfo和customerInfo都在第二层,这时就和layui要求的数据格式发生了冲突,但为了不修改后台json的数据格式,解决方案:
方案1:
{field: 'branchName', title: '公司名称', width:180, sort: true,templet:function(res){
console.log(res);
console.log(注意这边的res已经不是后台返回的res了,而是相当于res.data)
return res.branchInfo.branchName;
}}
方案2:
{field: 'd.branchInfo.branchName', title: '公司名称', width:180, sort: true,templet:'<div>{{d.branchInfo.branchName}}</div>'}