可以是数组,也可以是数组对象,看需求定义 let val = '' for (let i = 0; i < this.allData.length; i++) { if (this.days >= this.allData[i].num) { val = i break } } 如果数据不规则,则先将数组进行排序 let allData= [ {name:'a',num:14}, {name:'b',num:5}, {name:'c',num:29}, {name:'d',num:33}, {…