enda
V2EX  ›  PHP

在 Laravel5.1 中使用 Pjax

  •  
  •   enda · Oct 28, 2015 · 2761 views
    This topic created in 4028 days ago, the information mentioned may be changed or developed.

    在 Laravel 5.* 的版本中,使用 Pjax 实现无刷新效果,以及酷炫的进度条

    项目地址:https://github.com/yccphp/pjax-for-laravel-5

    求 star

    求 star

    求 star

    起因

    群里面的朋友老是在问 laravel 怎么和 pjax 结合,于是今天早上答应了给大家写一篇文章,到准备写的时候,发现其实挺简单的,也没有多少可写的东西,于是乎,干脆直接封装成包,大家直接安装用就好了

    感谢以下开源项目

    1. jquery.pjax.js

    2. nprogress

    效果

    <img src="http://www.phpyc.com/images/pjax.jpg" align=center />

    安装

    1.在 composer.json 的 require 里 加入

    "yuanchao/pjax-for-laravel-5": "dev-master"
    

    2.执行 composer update

    3.在 config/app.php 的 providers 数组加入一条

    YuanChao\Pjax\EndaPjaxServiceProvider::class
    

    4.在 Kernel 的 $middleware 数组里添加

    \YuanChao\Pjax\EndaPjaxMiddleware::class,
    

    5.执行 php artisan vendor:publish

    使用

    要先引入 jquery

    在布局文件中,插入以下代码

    @include('pjax::pjax')
    

    交流

    欢迎加入 laravel 学习小组交流:365969825

    2 replies  •  2015-10-29 09:59:13 +08:00
    enda
    enda
    OP
    Oct 28, 2015
    1
    自己消灭零回复
    freefcw
    freefcw
    Oct 29, 2015
    2
    不错不错,支持一个
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   791 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 23:32 · PVG 07:32 · LAX 15:32 · JFK 18:32
    ♥ Do have faith in what you're doing.