Bootstrap 已编辑的导航栏未显示在laravel和vue项目的视图中

pcrecxhr  于 2023-09-28  发布在  Bootstrap
关注(0)|答案(2)|浏览(83)

我用laravel new projectname创建了一个新的Laravel项目。所以它的选项很少,我选择的设置是jetstreaminertiaapi, dark, ssr。但是,当我在app.blade.php中通过在左侧添加一个项并编译和运行它来编辑导航栏部分时,我的页面没有显示更改。我还希望登录和注册链接也在左边。我还尝试添加一个旋转木马,这是工作,和导航栏(但它不工作)。我的主机没有显示任何错误或警告。
我做了什么。
composer require laravel/uiphp artisan ui bootstrap --authnpm install && npm run devnpm install @vitejs/plugin-vue --save-devnpm install vite-plugin-style-import sassnpm install vite-plugin-sass --save-devnpm install sass-loaderphp artisan optimize:clear
我编辑的-基本上是从右边复制到左边

<div id="app">
        <nav class="navbar navbar-expand-md navbar-white bg-white">
            <div class="container">
                <a class="navbar-brand" href="{{ url('/') }}">
                    {{ config('app.name', 'Laravel') }}
                </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">
                    <!-- Left Side Of Navbar -->
                    <ul class="navbar-nav me-auto">
                        {{--Added part--}}
                        @guest
                            @if (Route::has('login'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                                </li>
                            @endif

                            @if (Route::has('register'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                                </li>
                            @endif
                        @else
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                    {{ Auth::user()->name }}
                                </a>

                                <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                        {{ __('Logout') }}
                                    </a>

                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>

                    <!-- Right Side Of Navbar -->
                    <ul class="navbar-nav ms-auto">
                        <!--Regenerated part -->
                        @guest
                            @if (Route::has('login'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('login') }}">{{ __('Login') }}</a>
                                </li>
                            @endif

                            @if (Route::has('register'))
                                <li class="nav-item">
                                    <a class="nav-link" href="{{ route('register') }}">{{ __('Register') }}</a>
                                </li>
                            @endif
                        @else
                            <li class="nav-item dropdown">
                                <a id="navbarDropdown" class="nav-link dropdown-toggle" href="#" role="button" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false" v-pre>
                                    {{ Auth::user()->name }}
                                </a>

                                <div class="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
                                    <a class="dropdown-item" href="{{ route('logout') }}"
                                       onclick="event.preventDefault();
                                                     document.getElementById('logout-form').submit();">
                                        {{ __('Logout') }}
                                    </a>

                                    <form id="logout-form" action="{{ route('logout') }}" method="POST" class="d-none">
                                        @csrf
                                    </form>
                                </div>
                            </li>
                        @endguest
                    </ul>
                </div>
            </div>
        </nav>

        <main class="py-4">
            @yield('content')
        </main>
    </div>

x6yk4ghg

x6yk4ghg1#

如果您想更改欢迎页面,您必须更新welcome.blade.php而不是app.blade.php,因为欢迎页面不是从app.blade.php扩展的,我的默认设置
因此,当您在app.blade.php中添加更改时,您可以在从该文件扩展的其他页面中看到更改,例如登录页面:

或者您可以从app.blade.php扩展welcome.blade.php现在您可以在欢迎页面中使用app.blade.php导航栏

@extends('layouts.app')

@section('content')
    your welcome.blade.php content 
@endsection
ztyzrc3y

ztyzrc3y2#

显然,带有inertialaravel new也会给予你tailwind。它与bootstrap有冲突。所以删除这个代码会使它工作

@tailwind base;
@tailwind components;
@tailwind utilities;

相关问题