layui-table渲染不出來


通過方法渲染

頁面代碼:

<table id="tableList" lay-filter="clublist"></table>

js代碼:

layui.use('table', function () {
    var table = layui.table;

    //返回的數據必須是code:0
    var tableIns = table.render({
        elem: '#tableList'
      , height: 450
      , url: '/admin/Club/Club.ashx' //數據接口
      , where: { action: 'getclublistbypage' }
      , page: true //開啟分頁
      , limit: 10
      , cols: [[ //表頭
        { field: 'ID', title: 'ID', width: 80, sort: true, fixed: 'left' }
        , { field: 'ClubName', title: '主辦方名稱', width: 180 }
        , { field: 'ClubIntro', title: '主辦方介紹', width: 180 }
        , { field: 'ClubLogo', title: '主辦方logo', width: 180 }
        , { field: 'IsDel', title: '是否可用', width: 120 }
        , { field: 'SponsorTypeID', title: '主辦方類型', width: 180 }
      ]]
    });

});

然后是接口返回的數據(使用官方的默認response)

{
  code: 0,
  msg: "",
  count: 1000,
  data: []
} 

要注意,其中code的值,官方是這么說的:

我理解的就是code反應的是你返回的數據是正確的還是錯誤的,假如不正確(不為0),那么頁面會一直渲染不出來,這個要注意,這個問題搞了半天


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM