livewire/volt

Could not find Livewire component in DOM tree when using Volt full-page

Open

#130 建立於 2025年1月30日

在 GitHub 查看
 (3 留言) (0 反應) (0 負責人)PHP (35 fork)user submission
help wanted

倉庫指標

Star
 (420 star)
PR 合併指標
 (30 天內沒有已合併 PR)

描述

Volt Version

1.6.6

Laravel Version

11.37.0

PHP Version

8.3.13

Database Driver & Version

No response

Description

When using Volt's full-page component within Blade section directive I cannot get $wire to work in JavaScript as it can't find current component.

Could not find Livewire component in DOM tree

Steps To Reproduce

  1. Create simple layout resources/views/layouts/bare.blade.php
<!DOCTYPE html>
<html>
<head>
<body>
@yield('body')
</body>
</html>
  1. Create Volt component resources/views/livewire/email.blade.php
<?php

use function Livewire\Volt\{layout, state};

layout('layouts.bare');
state('email', 'test@example.com');

?>

<div>
    @section('body')
    <p x-data="{
        email: $wire.$get('email')
    }">Your email is: <span x-text="email"></span></p>
    @endsection
</div>
  1. Add routing in routes/web.php
<?php

use Livewire\Volt\Volt;

Volt::route('/email', 'email');

Because our alpine component is within blade's @section directive, it cannot find current Livewire component.

貢獻者指南