zoukankan      html  css  js  c++  java
  • laravel 中url使用

    laravel 辅助函数url()和asset()区别

    https://laravel-admin.org/docs/zh/1.x/installation

    url('img/home1/'),生成的链接:http://localhost/img/home1/

    url("/posts/{$post->age}",['post' => 1, 'comment' => 3])  生成的链接:  http://www.blog.com/posts/20/1/3

    url('img/home1/','test'),生成的链接:http://localhost/img/home1/test

    url('img/edit',['id'=>$v->id])  生成的链接: http://www.blog.com/news/edit/56 而不是http://www.blog.com/news/edit?id=56

    url('img/home1/','test',true),生成的链接:https://localhost/img/home1/test

    asset('img/home1/'),生成的链接:http://localhost/img/home1/

    asset('img/home1/',true),生成的链接:https://localhost/img/home1/

    url()

    通过url辅助函数(路由)生成:
    location.href = "{{url('user/index')}}";

    或者:location.href = "{{url::to('user/index')}}";

    route()

    通过别名(路由)生成,前提是在注册路由的时候要指定别名,例如:Route::get('user/index',['as' => 'user/index1', 'uses' => 'UserController@index']);
    location.href = "{{route('user/index1')}}";

    或者:location.href = "{{URL::route('user/index1')}}";

     route('shitu_luyou',['post' => 1, 'comment' => 3])   http://www.blog.com/shitu?post=1&comment=3

    action()

    通过控制器、方法名生成(路由不要指定别名,否则会报错!):
    location.href =  "{{action('UserController@index',['id'=>1,'author'=>'admin'])}}";
    或者:location.href =  "{{URL::action('UserController@index',['id'=>1,'author'=>'admin'])}}";

  • 相关阅读:
    HDU5914
    HDU1087(dp)
    HDU1711(KMP)
    HDU1251(字典树)
    HDU3068(Manacher算法)
    POJ2187(旋转卡壳)
    HDU1392(凸包)
    CodeForces 722B
    CodeForces 722A
    CodeForces 721B
  • 原文地址:https://www.cnblogs.com/as3lib/p/14449289.html
Copyright © 2011-2022 走看看