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'])}}";

  • 相关阅读:
    用chardet判断字符编码的方法
    NLP--edit distance
    nfc是什么?nfc功能是什么?
    【转载】推荐系统的十大挑战
    python--网络爬虫一
    【转载】双调欧几里得距离的算法原理
    Java并发编程:线程池的使用
    Java集合--HashMap源码剖析
    java中集合类详解
    java collection接口源码
  • 原文地址:https://www.cnblogs.com/as3lib/p/14449289.html
Copyright © 2011-2022 走看看