This commit is contained in:
satori 2024-12-07 06:57:03 +08:00
parent 7937a902c7
commit 7ff160e1d7

11
main.js
View File

@ -3,7 +3,6 @@ import { createElement, div, table, thead, tbody, tr, th, td } from '@laniakeasu
const rest = await fetch('http://localhost:2000/api').then(res => res.json()) const rest = await fetch('http://localhost:2000/api').then(res => res.json())
document.body.appendChild(div.childs([ document.body.appendChild(div.childs([
div.text('航班信息'),
table.childs([ table.childs([
thead.childs([ thead.childs([
tr.childs([ tr.childs([
@ -29,14 +28,8 @@ document.body.appendChild(div.childs([
])) ]))
const metrics = await fetch('http://localhost:2000/api/metrics').then(res => res.json()) const metrics = await fetch('http://localhost:2000/api/metrics').then(res => res.json())
const context = createElement({ width: 800, height: 200 }, 'canvas')
// 创建图表
const context = createElement({
width: 800,
height: 200,
}, 'canvas')
document.body.appendChild(context)
new Chart(context, { new Chart(context, {
type: 'line', type: 'line',
data: { data: {
@ -59,3 +52,5 @@ new Chart(context, {
} }
} }
}) })
document.body.appendChild(context)