1.遍历数组,删除不要的数据;
2.重新遍历数组进行替换
先删除再替换
this.seriesData && this.seriesData.forEach((item, index) => {
//删除名字为team这条数据
if (item.typeName === 'team') {
this.seriesData.splice(index, 1)
}
})
//替换statisCount为value,替换typeName为name,g是替换全部,i不区分大小写
this.seriesData && this.seriesData.forEach((item, index) => {
this.seriesData[index] = JSON.parse(
JSON.stringify(item)
.replace(/statisCount/gi, 'value')
.replace(/typeName/gi, 'name')
)
// this.seriesData.push({
// value: i.statisCount,
// name: i.typeName
// })
})