[{index: 0, bg: "rgba(134,115,230,0.55)", discount: 250},
{index: 1, bg: "rgba(134,115,230,0.55)", discount: 250},
{index: 2, bg: "rgba(134,115,230,0.55)", discount: 250},
{index: 3, bg: "rgba(97,199,242,0.4)", discount: 0},
{index: 4, bg: "rgba(97,199,242,0.4)", discount: 0}]
合并之后变成[{index:'00:00-02:00', discount: 250},
{index:'03:00:04:00', discount: 0}]
首先你这样的数据结构有问题,可以先思考一下定义一个合适的数据结构来完成需求的功能,
你要的结果: