Dynamic paging passes paging parameters through GET parameters (via QueryString), with the default paging parameter name being page.

    The example is as follows:

    1. package main
    2. import (
    3. "github.com/gogf/gf/v2/frame/g"
    4. "github.com/gogf/gf/v2/net/ghttp"
    5. "github.com/gogf/gf/v2/os/gview"
    6. )
    7. func main() {
    8. s := g.Server()
    9. s.BindHandler("/page/demo", func(r *ghttp.Request) {
    10. page := r.GetPage(100, 10)
    11. buffer, _ := gview.ParseContent(`
    12. <html>
    13. <head>
    14. <style>
    15. a,span {padding:8px; font-size:16px;}
    16. div{margin:5px 5px 20px 5px}
    17. </style>
    18. </head>
    19. <body>
    20. <div>{{.page1}}</div>
    21. <div>{{.page2}}</div>
    22. <div>{{.page3}}</div>
    23. <div>{{.page4}}</div>
    24. </body>
    25. </html>
    26. `, g.Map{
    27. "page1": page.GetContent(1),
    28. "page2": page.GetContent(2),
    29. "page3": page.GetContent(3),
    30. "page4": page.GetContent(4),
    31. })
    32. r.Response.Write(buffer)
    33. })
    34. s.SetPort(8199)
    35. s.Run()
    36. }

    In this example, we demonstrate four predefined paging styles and pass paging parameters via GET. After execution, the output is shown as below:

    Pagination - Dynamic Paging - 图1