首页 > 解决方案 > 如何将数组的值显示为逗号分隔值

问题描述

31: (2) ["https://localhost:44375/api/Image/2388", "https://localhost:44375/api/Image/2388"]

我得到了这样的价值,但我想展示它,

https://localhost:44375/api/Image/2388, https://localhost:44375/api/Image/2388

我怎样才能做到这一点?

标签: typescriptangular7

解决方案


您可以使用array#join

join() 方法通过连接数组(或类似数组的对象)中的所有元素创建并返回一个新字符串,并用逗号或指定的分隔符字符串分隔。

const data = ["https://localhost:44375/api/Image/2388", "https://localhost:44375/api/Image/2388"],
result = data.join(', ');
console.log(result);


推荐阅读