How to achieve this kind of shrinking paging?

above (Zhihu effect)

give me json backstage

{
    "newe_page":1, //
    "page_count":52, //
}

to find out how to achieve the effect shown above, answer

Mar.21,2021

if you know the total number of pages, you can draw all the pages. 1, 2, 3, 4, 5, 5, 5, 6, 6, and n, and you can also know whether you need to add an ellipsis. For example, if the rule of Zhihu is that the total number is greater than 5, you can add it.

once the current number of pages is known, you can decide which number turns gray, and you can also know whether to add "previous / next page";

once the total number of pages and the current number of pages are known, you can know where to add ellipses.

at this point, all the requirements have been implemented.


the paging component is so mature that I don't feel the need to reinvent the wheel.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1bf2b12-3166c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1bf2b12-3166c.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?