Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/281.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何使用laravel 5.4制作工作菜单选项卡_Php_Laravel_Laravel 5_Laravel 4_Laravel 5.2 - Fatal编程技术网

Php 如何使用laravel 5.4制作工作菜单选项卡

Php 如何使用laravel 5.4制作工作菜单选项卡,php,laravel,laravel-5,laravel-4,laravel-5.2,Php,Laravel,Laravel 5,Laravel 4,Laravel 5.2,我正在研究Laravel 5.4 我创建了一个菜单,其中有三个选项卡“主页”、“关于”和“联系人”。当我点击主页时,它应该在主页上。当点击关于,它应该在关于页上 web.php: <?php Route::get('/', function() { return View('method1.home'); }); Route::get('about', function() { return View('method1.about'); }); @extends('method1.da

我正在研究Laravel 5.4 我创建了一个菜单,其中有三个选项卡“主页”、“关于”和“联系人”。当我点击主页时,它应该在主页上。当点击关于,它应该在关于页上

web.php:

<?php

Route::get('/', function()
{
return View('method1.home');
});
Route::get('about', function()
{
return View('method1.about');
});
@extends('method1.dashboard')
@section('content')
 <h1>This is home page</h1>
@endsection
@extends('method1.dashboard')
@section('content')
 <h1>This is about page</h1>
@endsection
@include('method1.includes.menu-header')
<li class="active"> <a href="/">Home</a></li>
<li> <a href="/about">About</a></li>
menu-header.blade.php是:

<?php

Route::get('/', function()
{
return View('method1.home');
});
Route::get('about', function()
{
return View('method1.about');
});
@extends('method1.dashboard')
@section('content')
 <h1>This is home page</h1>
@endsection
@extends('method1.dashboard')
@section('content')
 <h1>This is about page</h1>
@endsection
@include('method1.includes.menu-header')
<li class="active"> <a href="/">Home</a></li>
<li> <a href="/about">About</a></li>
  • 但当我点击主页或关于页面时。它显示找不到页面

    我的laravel项目文件夹名为管理员\u laravel。当我运行时,它显示主页,当运行时,它显示关于页面


    但当我点击“关于菜单”按钮时,浏览器中会显示链接。这意味着它没有与一起运行,页面也没有显示。

    您缺少了一些内容,要快速修复,您可以执行以下操作:

    <li class="active"> <a href="{{ url('/') }}">Home</a></li>
    <li> <a href="{{ url('about') }}">About</a></li>
    
    然后:


  • 以下是详细信息:

    您缺少一些内容,要快速修复,您可以执行以下操作:

    <li class="active"> <a href="{{ url('/') }}">Home</a></li>
    <li> <a href="{{ url('about') }}">About</a></li>
    
    然后:


  • 以下是详细信息:

    您正在对URL进行硬编码。当您有
  • 时,您告诉浏览器从域的根目录转到
    关于
    路径(这是在URL前面加
    /
    前缀时发生的情况),在本例中为
    http://localhost/

    有几件事你应该做。首先,设置项目的基本URL,您可以在.env文件中更新
    APP\u URL

    或config/app.php中的
    url
    选项

    其次,在Laravel中生成URL时,有很多选项。如果未使用命名路由,则应使用
    url
    helper方法生成url:

    <li><a href="{{ url('about') }}">About</a></li>
    

  • 这将确保您的URL基于项目的根,而不是域的根。当您将
    url
    与上述正确设置结合使用时,将正确生成url。

    您正在对url进行硬编码。当您有
  • 时,您告诉浏览器从域的根目录转到
    关于
    路径(这是在URL前面加
    /
    前缀时发生的情况),在本例中为
    http://localhost/

    有几件事你应该做。首先,设置项目的基本URL,您可以在.env文件中更新
    APP\u URL

    或config/app.php中的
    url
    选项

    其次,在Laravel中生成URL时,有很多选项。如果未使用命名路由,则应使用
    url
    helper方法生成url:

    <li><a href="{{ url('about') }}">About</a></li>
    

  • 这将确保您的URL基于项目的根,而不是域的根。当您将
    url
    与上述正确设置结合使用时,您的url将正确生成。

    您正在根目录中显式链接到关于页面可能重复的
    您正在根目录中显式链接到关于页面可能重复的url方法正在工作。但APP_URL或'URL'=>env('APP_URL',')不起作用。URL方法起作用。但是APP_URL或'URL'=>env('APP_URL',')不起作用