第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

一個坑?response 不配置會顯示接口調用成功,有返回數(shù)據(jù),但是不渲染頁面

- -、真奇怪,老師演示的代碼沒有配置為什么會渲染

```js

let?table?=?layui.table;

table.render({
????elem:?'#customerList',?//?table的id
????url:?'/customer/list',?//?數(shù)據(jù)接口
????page:?true,??//開啟分頁
????response:{?//?這個不配置,不會渲染
????????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ù)長度
????????????"data":?res.data.records?//解析數(shù)據(jù)列表
????????};
????},
????cols:?[[?//?表頭
????????{field:?'realName',?title:?'真實姓名'},
????????{field:?'sex',?title:?'性別'},
????????{field:?'age',?title:?'年齡'},
????????{field:?'phone',?title:?'手機號碼'},
????????{field:?'createTime',?title:?'創(chuàng)建時間'},
????????{title:?'操作',?toolbar:?'#barDemo'}
????]]
});

```

正在回答

1 回答

我也遇到了,顯示了msg的值,但未顯示數(shù)據(jù)。原因為“code”的值不為0。

parseData:?function?(res)?{?//res?即為原始返回的數(shù)據(jù)
????????return?{
????????????"code":?res.code,?//解析接口狀態(tài)
????????????"msg":?res.msg,?//解析提示文本
????????????"count":?res.data.count,?//解析數(shù)據(jù)長度
????????????"data":?res.data.records?//解析數(shù)據(jù)列表
????????};
????}


此段代碼中的code值,直接定義為0,否則layui認為數(shù)據(jù)請求失敗。

即:

parseData:?function?(res)?{?//res?即為原始返回的數(shù)據(jù)
????????return?{
????????????"code":?0,?//解析接口狀態(tài)
????????????"msg":?res.msg,?//解析提示文本
????????????"count":?res.data.count,?//解析數(shù)據(jù)長度
????????????"data":?res.data.records?//解析數(shù)據(jù)列表
????????};
????}


0 回復 有任何疑惑可以回復我~

舉報

0/150
提交
取消

一個坑?response 不配置會顯示接口調用成功,有返回數(shù)據(jù),但是不渲染頁面

我要回答 關注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網(wǎng)微信公眾號