slice对数组进行截取

位置:首页 / 技术中心 / 杂项

杂项 Admin 2025-12-19 11:49:04 97
    // 为民服务
     toServeThePeople(){
       toServeThePeople({
          pageNum:1,
          pageSize:15,
          source:0
       }).then((res) => {
         this.serveThePeople = res.rows;
         // 按照serveThePeople里的activityTime倒序排序
         this.serveThePeople.sort((a, b) => new Date(b.activityTime) - new Date(a.activityTime));
         this.serveThePeople = this.serveThePeople.slice(0, 5);
         console.log(this.serveThePeople,'为民服务')
       });
     },
18455111359 扫描二维码