简体   繁体   English

Laravel:在本地使用引导程序出现问题

[英]Laravel : Problem using bootstrap locally

I'm having problem using bootstrap locally, if i use bootstrap like this:如果我像这样使用引导程序,我在本地使用引导程序时遇到问题:

<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

it will load very quick, however when i downloaded bootstrap and use it locally on the public folder like this:它会很快加载,但是当我下载引导程序并在公共文件夹上本地使用它时,如下所示:

<link rel="stylesheet" href="{{ asset('bootstrap/css/bootstrap.min.css') }}" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">

I get an error of "Maximum execution time of 60 seconds exceeded", the folder was placed correctly in "public/bootstrap/css/bootstrap.min.css", how to fix this?我收到“超过 60 秒的最大执行时间”的错误,该文件夹被正确放置在“public/bootstrap/css/bootstrap.min.css”中,如何解决这个问题?

This is my index.php这是我的 index.php

<?php

/**
 * Laravel - A PHP Framework For Web Artisans
 *
 * @package  Laravel
 * @author   Taylor Otwell <taylor@laravel.com>
 */

define('LARAVEL_START', microtime(true));

/*
|--------------------------------------------------------------------------
| Register The Auto Loader
|--------------------------------------------------------------------------
|
| Composer provides a convenient, automatically generated class loader for
| our application. We just need to utilize it! We'll simply require it
| into the script here so that we don't have to worry about manual
| loading any of our classes later on. It feels great to relax.
|
*/

require __DIR__ . '/../vendor/autoload.php';

/*
|--------------------------------------------------------------------------
| Turn On The Lights
|--------------------------------------------------------------------------
|
| We need to illuminate PHP development, so let us turn on the lights.
| This bootstraps the framework and gets it ready for use, then it
| will load up this application so that we can run it and send
| the responses back to the browser and delight our users.
|
*/

$app = require_once __DIR__ . '/../bootstrap/app.php';

/*
|--------------------------------------------------------------------------
| Run The Application
|--------------------------------------------------------------------------
|
| Once we have the application, we can handle the incoming request
| through the kernel, and send the associated response back to
| the client's browser allowing them to enjoy the creative
| and wonderful application we have prepared for them.
|
*/

$kernel = $app->make(Illuminate\Contracts\Http\Kernel::class);

$response = $kernel->handle(
    $request = Illuminate\Http\Request::capture()
);

$response->send();

$kernel->terminate($request, $response);

Try installing it with npm and compiling it with Laravel Mix.尝试使用 npm 安装它并使用 Laravel Mix 编译它。 Its very easy to do.它很容易做到。

In your console在您的控制台中

npm install bootstrap
npm update

In your /resources/js/app.js在你的/resources/js/app.js

import 'bootstrap';
import 'bootstrap/dist/css/bootstrap.min.css';

And finally, in your /resources/views/layout.blade.php最后,在您的/resources/views/layout.blade.php

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

Now, we can compile the script like so:现在,我们可以像这样编译脚本:

npm run dev

Worked for me on the first try.第一次尝试为我工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM