gpt4 book ai didi

node.js - NodeJs如何在控制台中显示结构化的表

转载 作者:搜寻专家 更新时间:2023-11-01 00:09:24 24 4
gpt4 key购买 nike

是否可以不安装新包?

这里我使用的是 cli-table 包.. enter image description here

有什么简单的方法吗?

最佳答案

您可以使用 console.table()无需安装任何 Node 模块的 API。 NodeJS 添加于:v10.0.0,Browser compatibility

const structDatas = [
{ handler: 'http', endpoint: 'http://localhost:3000/path', method: 'ALL' },
{ handler: 'event', endpoint: 'http://localhost:3000/event', method: 'POST' },
{ handler: 'GCS', endpoint: 'http://localhost:3000/GCS', method: 'POST' }
];
console.table(structDatas);

终端中的标准输出是这样的:

enter image description here

关于node.js - NodeJs如何在控制台中显示结构化的表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47228227/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com