我有一个表Message
,其中包含:
"message": [
"New Message of the day",
"Message 1",
"Message 2"
]
我在项目界面中显示了结果,结果显示如下:
New Message of the day, Message 1, Message 2
如何通过小功能将,
替换为##
?
谢谢
答案 0 :(得分:1)
您正在寻找https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/join。
var obj = {
"message": [
"New Message of the day",
"Message 1",
"Message 2"
]
};
console.log(obj.message.join("##"));
答案 1 :(得分:0)
let messages= [
"New Message of the day",
"Message 1",
"Message 2"
]
console.log(messages.join('##'))