【问题标题】:Blank Page in Google Chrome谷歌浏览器中的空白页
【发布时间】:2020-03-26 11:50:20
【问题描述】:

尝试使用 Laravel + Blade 加载我自己创建的页面,但浏览器只显示输出一秒钟然后消失。我不知道出了什么问题,我的代码中的一切都运行良好且没有错误......有什么想法吗???

我正在使用 php -S 127.0.0.1:8000 -t public 运行此页面

这是 web.php:

Route::get('/products/create', 'ProductsController@create');

这是 ProductsController.php:

public function create(){
    return view('products.create');
}

这是create.blade.php:

@extends('layouts.app')
@section('content')
<div class="container">
    <h1>Add new product</h1>
    <form action="/products" method="POST">
        @csrf
        <div class="container">
            <div class="form-group row">
                <label for="pName" class="col-md-4 col-form-label">Product name</label>
                <input id="pName" 
                    name="pName"
                    type="text" 
                    class="form-control @error('pName') is-invalid @enderror" 
                    value="{{ old('pName') }}"  
                    autocomplete="pName" 
                    autofocus>
            </div>
            <div class="form-group row">
                <label for="pCat" class="col-md-4 col-form-label">Category</label>
                <input id="pCat" 
                    name="pCat"
                    type="text" 
                    class="form-control @error('pCat') is-invalid @enderror" 
                    value="{{ old('pCat') }}"  
                    autocomplete="pCat" 
                    autofocus>
            </div>
        </div>
       <button class="btn btn-primary" type="submit">Submit</button>
    </form>
</div>
@endsection

这是 webpack.mix.js:

const mix = require('laravel-mix');

/*
 |--------------------------------------------------------------------------
 | Mix Asset Management
 |--------------------------------------------------------------------------
 |
 | Mix provides a clean, fluent API for defining some Webpack build steps
 | for your Laravel application. By default, we are compiling the Sass
 | file for the application as well as bundling up all the JS files.
 |
 */

mix.js('resources/js/app.js', 'public/js')
   .sass('resources/sass/app.scss', 'public/css')
   .mixbrowserSync('localhost:8000');

似乎@extends('layouts.app') 不起作用,因为当我删除它时,页面可以运行。有什么解决方案可以解决它还是缺少一些要安装的依赖项??

【问题讨论】:

  • 你检查浏览器控制台了吗?
  • 是的,我做到了,但它没有显示任何错误。刚刚看到这个“你在开发模式下运行 Vue。确保在部署生产时打开生产模式。”
  • 您需要完成这些步骤才能拥有您的 Javascript 和 CSS 文件 compiled。你成功完成了吗?

标签: php laravel laravel-blade


【解决方案1】:

查看通常位于 /storage/logs/laravel.log 的 Laravel 日志文件

你可能想用工匠来代替它:

php artisan serve

本地开发服务器 如果您在本地安装了 PHP 并且您 想使用 PHP 的内置开发服务器为您的 应用程序,您可以使用 serve Artisan 命令。该命令将 在http://localhost:8000 启动一个开发服务器:

https://laravel.com/docs/master/logging

https://laravel.com/docs/master/installation

【讨论】:

  • 是的,我确实尝试过 php artisan serve,它在 Laravel 开发服务器启动时响应我 127.0.0.1:8000,我添加了我在 web.php 和 route.js 中编写的路径,好吧它只是最终继续加载该页面......
猜你喜欢
  • 1970-01-01
  • 2016-11-19
  • 2016-07-09
  • 1970-01-01
  • 1970-01-01
  • 2023-03-09
  • 2010-09-07
  • 2016-05-12
  • 2012-01-21
相关资源
最近更新 更多