【问题标题】:Getting View [app] not found error in my Inertia laravel app在我的 Inertia laravel 应用程序中获取 View [app] not found 错误
【发布时间】:2021-04-01 06:49:33
【问题描述】:

我正在尝试在我的 laravel 应用中使用惯性。我的应用不需要jetstream,所以我不会使用它。于是我就去惯性的网站https://inertiajs.com/安装了,但是不知道是不是做对了。

我在页面上遇到的错误是

未找到查看 [应用]。

这就是我的 ProductController 中的内容

public function index()
{
    return Inertia::render('components/products/Index');
}

这是我的 Index.vue

<template>
    <div>
        <h1>Welcome</h1>
        <p>Hello, welcome to your first Inertia app!</p>
    </div>
</template>

<script>
    export default {
        components: {

        },
        props: {

        },
    }
</script>

在我的 app.blade.php 中

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta http-equiv="x-ua-compatible" content="ie=edge">

    <title>Admin</title>

    <link rel="stylesheet" href="/vendor/adminlte/plugins/fontawesome-free/css/all.min.css">
    <link rel="stylesheet" href="/css/style.css">

</head>
<body class="hold-transition sidebar-mini">
    <div class="wrapper">

    <!-- Navbar -->
    <nav class="main-header navbar navbar-expand navbar-white navbar-light">

        <!-- Left navbar links -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="index3.html" class="nav-link">Home</a>
            </li>
            <li class="nav-item d-none d-sm-inline-block">
                <a href="#" class="nav-link">Contact</a>
            </li>
        </ul>

        <!-- Right navbar links -->
        <ul class="navbar-nav ml-auto">

            <li class="nav-item dropdown user-menu">
                <a href="#" class="nav-link dropdown-toggle" data-toggle="dropdown"><span>{{ Auth::user()->name }}</span></a>
                <ul class="dropdown-menu dropdown-menu-lg dropdown-menu-right">
                    <li class="user-header bg-primary h-auto">
                        <p class="mt-0"><span>{{ Auth::user()->name }}</span><small><span>{{ Auth::user()->title }}</span></small></p>
                    </li>
                    <li class="user-footer">
                        <a class="btn btn-default btn-flat float-right btn-block" href="#" onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
                            <i class="fa fa-fw fa-power-off"></i> Log Out
                        </a>

                        <form id="logout-form" action="{{ route('logout') }}" method="POST" style="display: none;">
                            @csrf
                        </form>
                    </li>
                </ul>
            </li>

        </ul>
    </nav>
    <!-- /.navbar -->

    <aside class="main-sidebar elevation-4">
        <a href="{{ route('home') }}" class="brand-link">
            <img src="/img/default-brand.png" class="brand-image img-circle elevation-3"
             style="opacity: .8">
        </a>
    </aside>

    <div class="content-wrapper">
        <div class="content-header">
            <div class="container-fluid">
                <div class="row mb-2">
                    <div class="col-sm-6">
                        <h1 class="m-0 text-dark">@yield('title')</h1>
                    </div>
                </div>
            </div>
        </div>

        <div class="content">
            <div class="container-fluid">
                @inertia
            </div>
        </div>
    </div>
</div>


<script src="/jquery/jquery.min.js"></script>
<script type="text/javascript" src="{{ mix('js/app.js') }}"></script>
</body>
</html>

我不确定我是否遗漏了其他任何东西。

【问题讨论】:

  • 你能补充更多关于your server-side setup的信息吗?您的app.blade.php 在哪里?中间件是如何配置的?已配置自定义根模板?

标签: laravel laravel-8 inertiajs


【解决方案1】:

如果您的 app.blade.php 文件位于视图下的布局文件夹内,请将其上移至视图文件夹下,即

来自 资源/视图/布局/app.blade.php

资源/视图/app.blade.php

【讨论】:

    【解决方案2】:

    在视图目录中找不到应用程序。试试这个。

    Route::get('/', function () {
        return view('layouts/app');
    });
    

    【讨论】:

      猜你喜欢
      • 2015-05-09
      • 2019-04-09
      • 2021-08-25
      • 2014-01-30
      • 1970-01-01
      • 1970-01-01
      • 2013-10-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多