简体   繁体   English

使用 Jetstream 在 Laravel 8 中添加新的 Livewire 组件时如何解决 RootTagMissingFromViewException 错误

[英]How to resolve RootTagMissingFromViewException error while adding new Livewire component in Laravel 8 with Jetstream

I'm trying to add a new Livewire component to Laravel 8 Jetstream but looks I'm doing something wrong and getting the following error.我正在尝试向 Laravel 8 Jetstream 添加一个新的 Livewire 组件,但看起来我做错了什么并收到以下错误。

Error:错误:

RootTagMissingFromViewException

Livewire\Exceptions\RootTagMissingFromViewException
Livewire encountered a missing root tag when trying to render a component. When rendering a Blade view, make sure it contains a root HTML tag

Route:路线:

// web.php
Route::middleware('auth')->group(function() {
    Route::get('/newEmployee', NewEmployee::class);
});

Controller:控制器:


// app/Http/Livewire/NewEmployee.php

namespace App\Http\Livewire;

use Livewire\Component;

class NewEmployee extends Component
{
    public function render()
    {
        return view('livewire.new-employee')->layout('layouts.app')->name('NewEmployee');
    }
}

View:看法:

<!-- resources/views/livewire/new-employee.blade.php  -->
<div>
    <div class="max-w-7xl mx-auto py-10 sm:px-6 lg:px-8">
            <h1> New Wmployee </h1>
    </div>
</div>

Won't (name) the method.不会(命名)该方法。 Please define:请定义:

return view('livewire.new-employee')->layout('layouts.app');

You need add any HTML Tags in your livewire BLADE file.您需要在 livewire BLADE 文件中添加任何 HTML 标签。 LiveWire need HTML TAG in BLADE file. LiveWire 需要 BLADE 文件中的 HTML 标签。 So add simple TEST PAGE in LIVEWIRE BLADE.因此,在 LIVEWIRE BLADE 中添加简单的 TEST PAGE。 Issue should resolved.问题应该解决。

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

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