×ðÁú¿­Ê±

thinkphpÔõÑù×ö·ÖÒ³

Ò»¡¢¿ØÖÆÆ÷ÖеĴúÂëʵÏÖ

ÔÚ¿ØÖÆÆ÷ÒªÁìÖÐ £¬ÎÒÃÇ¿ÉÒÔͨ¹ýTP¿ò¼ÜÄÚÖõķÖÒ³Àà\think\paginator\driver\BootstrapÀ´Íê³ÉÊý¾Ý·ÖÒ³¹¦Ð§µÄʵÏÖ¡£ÎÒÃÇ¿ÉÒÔÏÈÅÌÎʳöÒª¾ÙÐзÖÒ³µÄÊý¾Ý £¬È»ºó½«ÅÌÎÊЧ¹ûת´ï¸ø·ÖÒ³Àà £¬È»ºóŲÓ÷ÖÒ³ÀàµÄrender()ÒªÁì¼´¿É¡£

ÏÂÃæÊÇÒ»¸ö¿ØÖÆÆ÷´úÂëµÄʾÀý£º

use \think\paginator\driver\Bootstrap;

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

public function index()

{

// ÅÌÎÊÎÄÕÂÁбíÊý¾Ý
$articles = Db::name('article')->paginate(10);

// ½«ÅÌÎÊЧ¹ûת´ï¸ø·ÖÒ³Àà
$page = $articles->render();

// ½«·ÖÒ³ºóµÄÊý¾Ýת´ï¸øÄ£°å
$this->assign('articles', $articles);
$this->assign('page', $page);

return $this->fetch('index');

µÇ¼ºó¸´ÖÆ

}

ÿҳÏÔʾÊý¾ÝÁ¿±»Ö¸¶¨Îª10 £¬ÕâÊÇÔÚʾÀý´úÂëÖÐͨ¹ýpaginate()ÒªÁìÖеIJÎÊý¾ÙÐÐÉèÖõÄ¡£$articles±äÁ¿Öд洢µÄÊÇÅÌÎʳöÀ´µÄÎÄÕÂÁбíÊý¾Ý £¬$page±äÁ¿Öд洢µÄ¾ÍÊÇ·ÖÒ³ºóµÄHTML´úÂë¡£

¶þ¡¢Ä£°åÖеĴúÂëʵÏÖ

ÔÚÄ£°åÖÐ £¬ÎÒÃÇ¿ÉÒÔ̫ͨ¹ýÒ³ÀàµÄrender()ÒªÁì·µ»Ø·ÖÒ³HTML´úÂë £¬È»ºóÔÚÒ³ÃæÉÏäÖȾ·ÖÒ³µ¼º½¡£

ÏÂÃæÊÇÒ»¸öÄ£°å´úÂëµÄʾÀý£º

{volist name="articles" id="article"}
    <li>{$article.title}</li>
{/volist}

µÇ¼ºó¸´ÖÆ

{$page}

µÇ¼ºó¸´ÖÆ

ÎÒÃÇʹÓÃÁËTP¿ò¼ÜµÄvolist±êÇ©ÔÚ´úÂëÖÐÑ­»·Êä³öÁËÎÄÕÂÁбí¡£ÎÒÃÇʹÓÃ{$page}ÔÚÑ­»·¿¢ÊºóÊä³ö·ÖÒ³µ¼º½µÄHTML´úÂë¡£

ÒÔÉϾÍÊÇthinkphpÔõÑù×ö·ÖÒ³µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

13452372176

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿