一個(gè)坑?response 不配置會(huì)顯示接口調(diào)用成功,有返回?cái)?shù)據(jù),但是不渲染頁(yè)面
- -、真奇怪,老師演示的代碼沒(méi)有配置為什么會(huì)渲染
```js
let?table?=?layui.table; table.render({ ????elem:?'#customerList',?//?table的id ????url:?'/customer/list',?//?數(shù)據(jù)接口 ????page:?true,??//開(kāi)啟分頁(yè) ????response:{?//?這個(gè)不配置,不會(huì)渲染 ????????statusName:'code',? ????????statusCode:200? ????}, ????parseData:?function?(res)?{?//res?即為原始返回的數(shù)據(jù) ????????return?{ ????????????"code":?res.code,?//解析接口狀態(tài) ????????????"msg":?res.msg,?//解析提示文本 ????????????"count":?res.data.count,?//解析數(shù)據(jù)長(zhǎng)度 ????????????"data":?res.data.records?//解析數(shù)據(jù)列表 ????????}; ????}, ????cols:?[[?//?表頭 ????????{field:?'realName',?title:?'真實(shí)姓名'}, ????????{field:?'sex',?title:?'性別'}, ????????{field:?'age',?title:?'年齡'}, ????????{field:?'phone',?title:?'手機(jī)號(hào)碼'}, ????????{field:?'createTime',?title:?'創(chuàng)建時(shí)間'}, ????????{title:?'操作',?toolbar:?'#barDemo'} ????]] });
```
2022-02-06
此段代碼中的code值,直接定義為0,否則layui認(rèn)為數(shù)據(jù)請(qǐng)求失敗。
即: