0

I am facing a problem in the menu bar which doesn't show result correctly. I am sharing a few lines.

index.blade.php: -

<nav class="navbar navbar-expand-lg navbar-light">
  <a class="navbar-brand" href="">Easy Service</a>
  <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
    <span class="navbar-toggler-icon"></span>
  </button>

  <div class="collapse navbar-collapse" id="navbarSupportedContent">
    <ul class="navbar-nav ml-auto">
      <li class="nav-item ">
        <a class="nav-link" href="">Home </a>
      </li>
      <li class="nav-item">
        <a class="nav-link" href="about">About</a>
      </li>
        <li class="nav-item">
        <a class="nav-link" href="services">Services</a>
      </li>

      <li class="nav-item">
        <a class="nav-link " href="contact">Contact</a>
      </li>

      <li class="es">
        <a href="#" class="nav-link" data-toggle="modal" data-target="#myModal">Login</a>
      </li>
    </ul>
</nav>

Here is another file.

web.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('index');
});
Route::get('/about', function () {
    return view('about');
});
Route::get('/contact', function () {
    return view('contact');
});
Route::get('/services', function () {
    return view('services');
});

When I open up the pages from the home page by clicking the links, the output is correct but when I open up the links through other pages then home page link is not working. If I put (/index) in web.php file, then it worked, but I don't want to show my home page link in URL with (/index). It is only by opening with showing the name with URL after a slash (/).

How can I link home page without showing URL on the browser?

Home Page with Empty slash Home Page with Empty slash About Page with Non-empty slash About Page with Non-empty slash

4

1 回答 1

1

如果它应该引用索引页面使用,请不要使用空href属性,因为当未填充时,链接将跟随到当前页面。或者您可以在 Laravel https://laravel.com/docs/5.8/urls#urls-for-named-routes中使用命名路由<a><a href="/">href

于 2019-03-04T16:31:03.823 回答