[Solved] Uncaught TypeError: Cannot create property ‘LAY_TABLE_INDEX’ on number ‘1’

table.js:2 Uncaught TypeError: Cannot create property ‘LAY_TABLE_INDEX’ on number ‘1’

Using the data table of the layui framework, render errors

Reason: when layui renders table data, the data value returned by the interface request should be in the form of * data: [{}, {}, {}], while my data form is in the form of data: {data: [{}, {}], statuscode: 1,…} *, so an error will be reported

Solution: parse the data in the parsedata function

table.render({
  elem: '  '
  ,url: '  ',
   parseData: function(res){
                console.log('Return Values',res)
                return {
                    "statusCode": res.statusCode, //Analyze interface status
                    "data": res.data.data //Parse the data list
                };
            },`

Similar Posts: