没有在Laravel 8中加载引导程序 [英] Not loading bootstrap in Laravel 8
问题描述
我刚刚开始使用Laravel 8,因此由于我的页面未加载引导程序,我该如何在Laravel 8中包括引导程序?
I have just started using Laravel 8, so how do I include bootstrap in Laravel 8 since my pages are not loading bootstrap?
在这种情况下,它不会以正确的样式加载列表组.
In this case it does not load the list group with the proper styling.
@extends('layouts. app')
@section('content')
<h1>{{ $title ?? '' }}</h1>
<ul class="list-group">
<li class="list-group-item">Web design</li>
<li class="list-group-item">programming</li>
<li class="list-group-item">SEO</li>
</ul>
@endsection
推荐答案
要在Laravel 8中安装Bootstrap 4,然后安装以下Laravel UI composer软件包以获取命令:
For install Bootstrap 4 in Laravel 8 then install following Laravel UI composer package to get command:
composer require laravel/ui
成功安装上述软件包后,我们就可以安装Bootstrap.
After successfully install above package then we are ready to install Bootstrap.
存在两种方法,一种是简单的Bootstrap安装安装,另一种是使用auth安装Bootstrap.
Exists 2 way to do that, one is a simple Bootstrap setup install and another is install Bootstrap with auth.
安装Bootstrap 4:
Install Bootstrap 4:
php artisan ui bootstrap
使用auth安装Bootstrap 4
Install Bootstrap 4 with auth
php artisan ui bootstrap --auth
现在您可以看到资源目录JS文件夹.
Now you can see your resource directory JS folder.
您还需要安装npm并运行它:
You also need to install npm and run it:
npm install
然后运行NPM
npm run dev
现在,您可以使用Bootstrap 4应用程序了.
Now you can work with your Bootstrap 4 app.
您可以在Blade模板的标题中使用这些行,包括以下行:
You can use it including these lines on the header of your Blade templates:
<head>
<script src="{{ asset('js/app.js') }}" defer></script>
<link href="{{ asset('css/app.css') }}" rel="stylesheet">
</head>
致谢
这篇关于没有在Laravel 8中加载引导程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!