zoukankan      html  css  js  c++  java
  • laravel 函数测试 --- Route::has()

    新建: D:laragonwww est esourcesviews .blade.php

        @if (Route::has('login'))
            <div class="top-right links">
                @auth
                    <a href="{{ url('/home') }}">Home</a>
                @else
                    <a href="{{ route('login') }}">Login</a>
    
                @endauth
            </div>
        @else
            <h3>没有定义login这个路由, 没办法这样访问  {{ url('/login') }}</h3>
       
        @endif
    
    加上@符号,双{}将不解析<br>
    Hello, @{{ name }} .
    
    {{ isset($name) ? $name : 'Default' }}
    除了使用三元运算符,Blade 还提供了更简单的方式:
    
    {{ $name or 'Default' }}
    
    

    新建:
    D:laragonwww est outesweb.php

    <?php
    
    /*
    |--------------------------------------------------------------------------
    | Web Routes
    |--------------------------------------------------------------------------
    |
    | Here is where you can register web routes for your application. These
    | routes are loaded by the RouteServiceProvider within a group which
    | contains the "web" middleware group. Now create something great!
    |
    */
    
    Route::get('/', function () {
        return view('welcome');
    });
    
    Route::get('/t', function () {
        return view('t');
    });
    
    Route::get('/login', function () {
        return view('t');
    })->name('login');
    
    //路由加参数:在/t.blade.php中可以使用变量 {{$name}}
    Route::get('/tname', function () {
        return view('t', ['name' => 'shen']);
    });
    

    如果 去掉->name('login'); 则找不到路由,Route::has('login') 和name('login'); 要成对出现 。万物有名。

  • 相关阅读:
    Java对象克隆
    Java对象toString()方法
    Java对象相等比较(Equals)
    数据传送到后端(二)
    前端数据传送至后端(一)
    jquery导航栏(方法1)
    js导航栏
    纯css导航栏
    jquery导航栏(方法2)
    带尖角的边框(方法二)
  • 原文地址:https://www.cnblogs.com/dreamfine/p/9041580.html
Copyright © 2011-2022 走看看