Das Dropdown-Menü der Navigationsleiste funktioniert in Laravel 8 nicht richtig
P粉460377540
P粉460377540 2023-12-16 11:55:20
0
1
676

Ich habe ein Problem mit der Navigationsleiste in Laravel 8; die gesamte Navigationsleiste wird in der Ansicht angezeigt, aber das Dropdown-Menü funktioniert nicht.

Tatsächlich öffnet sich das Dropdown-Menü nicht, wenn ich darauf klicke.

Das ist layout.blade.php:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="{{asset('css/app.css')}}">
    <title>Document</title>
</head>
<body>
    
    <x-navbar/>
    
    {{$slot}}

    <script src="{{asset('js/app.js')}}"></script>
</body>
</html>

Das ist navbar.blade.php:

<nav class="navbar navbar-expand-lg navbar-light bg-light">
  <div class="container-fluid">
    <a class="navbar-brand" href="#">Navbar</a>
    <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-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 me-auto mb-2 mb-lg-0">
        <li class="nav-item">
          <a class="nav-link active" aria-current="page" href="#">Home</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="#">Link</a>
        </li>
        <li class="nav-item dropdown">
          <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
            Dropdown
          </a>
          <ul class="dropdown-menu" aria-labelledby="navbarDropdown">
            <li><a class="dropdown-item" href="#">Action</a></li>
            <li><a class="dropdown-item" href="#">Another action</a></li>
            <li><hr class="dropdown-divider"></li>
            <li><a class="dropdown-item" href="#">Something else here</a></li>
          </ul>
        </li>
        <li class="nav-item">
          <a class="nav-link disabled">Disabled</a>
        </li>
      </ul>
      <form class="d-flex">
        <input class="form-control me-2" type="search" placeholder="Search" aria-label="Search">
        <button class="btn btn-outline-success" type="submit">Search</button>
      </form>
    </div>
  </div>
</nav>

Und die Ansicht home.blade.php lautet:

<x-layout>
    <h1>Hello!!!</h1>
</x-layout>

P粉460377540
P粉460377540

Antworte allen(1)
P粉851401475

请尝试使用此方法,否则可能会出现拼写错误。

@include('inc.navbar')
//      @include('FOLDER_NAME.FILE_NAME')

还要检查文档! https://laravel.com/docs/9.x/blade#include-子视图

Neueste Downloads
Mehr>
Web-Effekte
Quellcode der Website
Website-Materialien
Frontend-Vorlage