本文實例講述了Laravel框架實現(xiàn)超簡單的分頁效果。分享給大家供大家參考,具體如下:
每頁展示5條數(shù)據(jù)
控制器
class indexCo extends Controller { public function cc () { $lists = UserAli:: orderBy('user_id','desc') -> paginate(5); return view('cc',compact('lists')); } }
layout/main.blade.php
!DOCTYPE html> html> head> title>Home/title> link rel="stylesheet" rel="external nofollow" rel="external nofollow" > /head> body> h1>Home/h1> p>Welcome to My web/p> /body> /html> !DOCTYPE html> html> head> title>About/title> /head> body> h1>About/h1> p>This is my first Laravel web/p> @yield("content") /body> /html>
cc模板
view/cc.blade.php
@extends('layout.main') @section("content") div> @foreach($lists as $value) div> 阿里賬號是:{{$value -> source}} time>{{$value -> add_time}}/time> /div> @endforeach /div> {{$lists -> links()}} @endsection
兩句話搞定分頁。
當(dāng)然,blade模板需要引入bootstrap,否則樣式是出不來的。
link rel="stylesheet" rel="external nofollow" rel="external nofollow" >
更多關(guān)于Laravel相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《Laravel框架入門與進(jìn)階教程》、《php優(yōu)秀開發(fā)框架總結(jié)》、《php面向?qū)ο蟪绦蛟O(shè)計入門教程》、《php+mysql數(shù)據(jù)庫操作入門教程》及《php常見數(shù)據(jù)庫操作技巧匯總》
希望本文所述對大家基于Laravel框架的PHP程序設(shè)計有所幫助。
標(biāo)簽:吐魯番 寧夏 遂寧 武威 常州 遵義 徐州 荊門
巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《Laravel框架實現(xiàn)超簡單的分頁效果示例》,本文關(guān)鍵詞 Laravel,框架,實現(xiàn),超,簡單,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。