对象数组如下:
![在这里插入图片描述](https://img-blog.csdnimg.cn/d0dea2e808254919babd499bcf837153.png?x-oss-process=image/watermark,type_d3F5LXplbmhlaQ,shadow_50,text_Q1NETiBAaHExMTExMTExMTE=,size_19,color_FFFFFF,t_70,g_se,x_16)
封装函数
getMaxIndex(arr = []) {
if (arr.length == 0) return -1;
var maxIndex = 0;
var max = arr[maxIndex].value;
arr.forEach((item, index) => {
if (item.value > max) {
max = item.value;
maxIndex = index;
}
});
return maxIndex;
}
this.getMaxIndex(data)