V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
enda
V2EX  ›  PHP

在 Laravel5.1 中使用 Pjax

  •  
  •   enda · 2015-10-28 16:20:03 +08:00 · 2026 次点击
    这是一个创建于 3104 天前的主题,其中的信息可能已经有所发展或是发生改变。

    在 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 条回复    2015-10-29 09:59:13 +08:00
    enda
        1
    enda  
    OP
       2015-10-28 16:35:58 +08:00
    自己消灭零回复
    freefcw
        2
    freefcw  
       2015-10-29 09:59:13 +08:00
    不错不错,支持一个
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   975 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 19:23 · PVG 03:23 · LAX 12:23 · JFK 15:23
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.