0

bootstrap-table的数据格式为

[
    {
        "id": 0,
        "name": "测试11111",
        "price": "¥0",
        "column1": "c10",
        "column2": "c20",
        "column3": "c30",
        "column4": "c40"
    },
    {
        "id": 1,
        "name": "测试1",
        "price": "¥1",
        "column1": "c10",
        "column2": "c20",
        "column3": "c30",
        "column4": "c40"
    },
    {
        "id": 2,
        "name": "测试2",
        "price": "¥2",
        "column1": "c10",
        "column2": "c20",
        "column3": "c30",
        "column4": "c40"
    },
    {
        "id": 3,
        "name": "测试3",
        "price": "¥3",
        "column1": "c10",
        "column2": "c20",
        "column3": "c30",
        "column4": "c40"
    },
    {
        "id": 4,
        "name": "测试4",
        "price": "¥4",
        "column1": "c10",
        "column2": "c20",
        "column3": "c30",
        "column4": "c40"
    }
    ]





后台返回我的格式为

{
  "msg":"查询成功",
  "errcode":0,
  "data":{
    "rows":[
      {
        "id":"17",
        "pharmacy_id":"4",
        "drug_id":"6",
        "price":"6.00",
        "update_time":"2017-02-15 10:22:21",
        "create_time":"2017-02-15 10:22:21",
        "status":"1",
        "drug_name":"苦参",
        "p_price":"20.00",
        "unit_text":"支"
      },
      {
        "id":"16",
        "pharmacy_id":"4",
        "drug_id":"5",
        "price":"5.00",
        "update_time":"2017-02-15 10:22:20",
        "create_time":"2017-02-15 10:22:20",
        "status":"1",
        "drug_name":"甘草",
        "p_price":"5.00",
        "unit_text":"袋"
      },
      {
        "id":"15",
        "pharmacy_id":"4",
        "drug_id":"4",
        "price":"4.00",
        "update_time":"2017-02-15 10:22:16",
        "create_time":"2017-02-15 10:22:16",
        "status":"1",
        "drug_name":"干姜",
        "p_price":"10.00",
        "unit_text":"克"
      }
    ],
    "total":"6"
  }
}

格式不一样 表格获取不到数据怎么改?

1个回答

0

已采纳

已解决,加上这个就好了

responseHandler: function(res) {
                return {
                    "total": res.data.total,//总页数
                    "rows": res.data.rows   //数据
                 };
            },

撰写答案