<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>开始使用 layui</title>
<link rel="stylesheet" href="https://www.layuicdn.com/layui/css/layui.css">
<!-- <link rel="stylesheet" href="./layui/css/layui.css"> -->
</head>
<body>
<div id="demo"></div>
<script src="https://www.layuicdn.com/layui/layui.js"></script>
<script>
layui.use(['table'], function () {
table = layui.table;
let arr1 = { dataquery1: { device: '50', ct: 1969, inter: 0 }, dataquery2: { device: '51', ct: 1959, inter: 00 } };
let arr2 = { dataquery1: { inter: 111 }, dataquery2: { inter: 222 } };
var data1 = [], data2 = [];
for (let key1 in arr1) {
data1.push(arr1[key1]);
}
for (let key2 in arr2) {
console.log(arr2[key2], '====arr2[key2]');
data2.push(arr2[key2]);
}
console.log(data1, data2);
for (let j = 0; j < data2.length; j++) {
data1[j].inter = data2[j].inter;
}
console.log(data1, data2);
let da = data1.concat(data2);
table.render({
elem: "#demo",
data: da,
cols: [[
{ field: "device", title: 'A' },
{ field: 'ct', title: 'B' },
{ field: 'inter', title: 'C' },
]]
});
});
</script>
</body>
</html>