<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                ### 1.相關鏈接 flask Paginate:[https://flask-paginate.readthedocs.io/en/latest/](https://flask-paginate.readthedocs.io/en/latest/) ### 2.添加測試數據 ``` # 添加測試帖子數據 @manager.command def create_test_post(): for i in range(1,205): title = "標題{}".format(i) content = "內容:{}".format(i) board = BoardModel.query.first() author = FrontUser.query.first() post = PostModel(title=title,content=content) post.board = board post.author = author db.session.add(post) db.session.commit() print("添加帖子測試完成") ``` ### 3.安裝 ``` pip install flask_paginate ``` ### 4.參數 ``` found:搜索時使用 * page:當前頁面 per_page:一頁上顯示的記錄數 page_parameter:包含頁面索引的GET參數的名稱(字符串)。如果您想同時迭代多個分頁對象,請使用它。defautl是'page'。 per_page_parameter:一個名字per_page喜歡page_parameter。默認為'per_page'。 * inner_window:當前頁面有多少鏈接 * outer_window:第一個/最后一個鏈接附近有多少個鏈接 prev_label:上一頁的文字,默認為'&laquo;' next_label:下一頁的文字,默認為'&raquo;' search:搜索與否? total:分頁記錄總數 display_msg:pagation信息的文本 search_msg:搜索信息的文本 record_name:記錄名稱顯示在分頁信息中 link_size:頁面鏈接的字體大小 alignment:分頁鏈接的對齊方式 href:為鏈接添加自定義href - 這支持使用post方法的表單。必須包含{0}才能格式化頁碼 show_single_page:決定單個頁面是否返回分頁 bs_version:bootstrap的版本,默認為2 css_framework:css框架,默認為'bootstrap' anchor:anchor參數,追加到頁面href format_total:數字格式總計,如1,234,默認為False format_number:數字格式的開始和結束,如1,234,默認為False ``` ### 5.初始化對象 ``` # 獲取page頁數參數 page = request.args.get(get_page_parameter(),type=int,default=1 # 傳入頁數參數,數據的總條數 pagination = Pagination( bs_version=3,page=page, total=PostModel.query.count(), outer_window=0, inner_window=2, ) ``` ### 6.每頁數據 ``` offset = (page-1) * config.PER_PAGE count = offset + config.PER_PAGE # 從第幾條開始顯示第end條數據 posts = PostModel.query.slice(offset,count) ``` ### 7.前端 ``` <ul class="post-list-group"> {% for post in posts %} <li> <div class="author-avatar-group"> <img src="{{ post.author.avatar or url_for('static',filename="common/images/logo.png") }}" alt=""> </div> <div class="post-info-group"> <p class="post-title">{{ post.title }}</p> <p class="post-info"> <span>作者:{{ post.author.username }}</span> <span>發表時間:{{ post.create_time }}</span> <span>評論:0</span> <span>閱讀:0</span> </p> </div> </li> {% endfor %} </ul> <div style="text-align: center"> {{ pagination.links }} </div> ``` ### 8.小細節 ``` paginate.links 可以自動完成點擊的模塊 ```
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看