Rumah > Soal Jawab > teks badan
Saya menghadapi masalah dengan bar navigasi dalam Laravel 8 khususnya, keseluruhan bar navigasi muncul pada paparan, tetapi menu lungsur tidak berfungsi.
Malah, bila saya klik, menu lungsur tidak dibuka.
Ini ialah 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>
Ini ialah 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>
Dan paparan home.blade.php ialah:
<x-layout> <h1>Hello!!!</h1> </x-layout>
P粉8514014752023-12-17 10:38:09
Sila cuba kaedah ini, jika tidak, anda mungkin mendapat ralat ejaan.
@include('inc.navbar') // @include('FOLDER_NAME.FILE_NAME')
Semak juga dokumentasi! https://laravel.com/docs/9.x/blade#include-subview