const pagination = (current,pagesize,total) => { const count = Math.ceil(total/pagesize);//总页数 return [1,current>=5&&'pre',...[current-2,current-1,current,current+1,current+2].filter(el=>el>1&&el<count),count-current>=5&&'next',count].filter(Boolean) } console.log(pagination(36,5,200))