const array = [ { text: 'a', style: { bold: true }}, { text: 'b', style: { bold: true }}, { text: 'c', style: { italic: true, bold: true }}, { text: 'd', style: { italic: true }}, { text: 'e', style: { italic: true }}, { text: 'f', style: { underline: true }},]类似这样的数组,期望格式化后是这样的const formatArray = [ { text: 'ab', style: { bold: true }}, { text: 'c', style: { italic: true, bold: true }}, { text: 'de', style: { italic: true }}, { text: 'f', style: { underline: true }},]根据完全相同的style属性将text值拼接, text有顺序要求,就是数组的索引,所以只合并相邻的具有相同style属性的元素。请大牛们指点迷津!
添加回答
举报
0/150
提交
取消
