解决了 ,
var btn = document.getElementById("button1"); btn.onclick = function() { layui.use("laypage", function() { var a = layui.laypage; a.render({ elem: nicePage.bar, limit: nicePage.limit, theme: nicePage.color, count: json.length, layout: nicePage.layout, jump: function(b) { document.getElementById(nicePage.table).innerHTML = function() { var c = [nicePage.returnHtml(nameList, widthList)], d = nicePage.returnList(json).concat().splice(b.curr * b.limit - b.limit, b.limit); layui.each(d, function(e, g) { var f = nicePage.returnTable(g); c.push(f) }); c.push(" </table></br>"); return c.join("") }() } }) }) }
{ "code": 1, "msg": "获取数据成功", "data": { [ { "medicineID": 1, "name": "止咳糖浆", "number": "20190078565", "factory":"山东某药厂", "produce":1567153189, "quality":"300", "purpose":"止咳信息" "price": "36.58" , "specs": "500ml/盒", "stock": 300, "unit": "升", }, { "medicineID": 2, "name": "止咳糖", "number": "20190078565", "factory":"山东某药厂", "produce":1567153189, "quality":"300", "purpose":"止咳信息" "price": "36.58" , "specs": "500ml/盒", "stock": 300, "unit": "升", }, ] } }
这样的怎么用
var json = []; $.ajax({ type: "post", async: false, url: "http://112.125.26.165/api/project1/?r=medicine/get-list", data: { token: 'ad3eab04c61b33e523fca08f17970622', type: 'json', list: 'page', start: "1", pageSize: "10" }, dataType: 'json', crossDomain: true, success: function(res) { jsons = res.data; }, error: function() { alert("错误"); } }); console.log(jsons); var json = jsons;
解决了