我在用Layui進行資料決議時,因為回傳的資料欄位與表頭的不相符,所以想用parseData進行決議成table的格式內容,但是回傳的資料有了,但后面的點不出來,怎么辦呢?使用的版本是2.5.5的Layui
table.render({
elem: '#test'
, url: CCSHmobi.website + "TaskPublishing/GetDeveloper"
, toolbar: '#toolbarDemo' //開啟頭部工具列,并為其系結左側模板
, defaultToolbar: ['filter', 'exports', 'print']
, title: '任務清單'
, cols: [[
{ field: 'id', title: 'ID', width: 80, fixed: 'left', unresize: true, sort: true }
, { field: 'WorkName', title: '任務名', edit: 'text' }
, { field: 'PublisherName', title: '發布者', edit: 'text', sort: true }
, { fixed: 'WorkTime', title: '發布時間', edit: 'text', sort: true }
, {
field: 'WorkingCondition', title: '任務狀態', sort: true, templet: function (res) {
if (res.WorkingCondition=="2") {
return '<em>進行中</em>'
}
}
}
, { fixed: 'right', title: '操作', toolbar: '#barDemo', }
]]
, page: true
,response: {
statusCode: 200 //規定成功的狀態碼,默認:0
}
, parseData: function (res) { //將原始資料決議成 table 組件所規定的資料
alert(res)
return {
"code": res.status, //決議介面狀態
"msg": res.message, //決議提示文本
"count": res.total, //決議資料長度
"data": res.data.item //決議資料串列
};
}
});
回傳的資料:{[{"WorkName":"測驗","PublisherName":"測驗","ExecutorName":"測驗","Woketime":"2020/05/01","Endtime":null,"WorkingCondition":"2","Description":"測驗","type":0}]}
uj5u.com熱心網友回復:
出現的錯誤是 Cannot read property 'item' of undefineduj5u.com熱心網友回復:
我已經知道問題所在了,我犯蠢了,格式錯了emm轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/40612.html
標籤:HTML5
