How to use laravel components with livewire lazy placeholder
P粉935883292
P粉935883292 2024-04-06 20:02:10
0
2
467

I want to add the skeleton of my laravel component inside a livewire 3 placeholder What I've tried so far:

Implement the Livewire class by including the Laravel component:

public function placeholder() { return <<<'HTML'  HTML; }

The above method does not render anything,

But when I try to use direct HTML like this:

public function placeholder() { return <<<'HTML'  HTML; }

good results, I prefer using laravel components because of its reusability So how to solve this problem

P粉935883292
P粉935883292

reply all (2)
P粉642919823

Just trying to make things simple. Can the Livewire component's view be rendered conditionally?

Example:

In your Livewire component

public $show_skeleton = true;

In the view of the Livewire component

           
@if ($show_skeleton) @endif

In your Livewire component class

public function showSkeleton() { $this->show_skeleton = true; } public function hideSkeleton() { $this->show_skeleton = false; }

Now use the above method to show and hide your skeleton.

    P粉035600555

    According to thedocumentation, you can do this in your configuration. So you create a view that renders the component and then set it in the configuration. This also saves you from having to define the same placeholder on every component.

    However, from the looks of it, you can pass in any string, so you can also just return the rendered view:view('view')->render(). Also, as before, you can just define a view in which to render the component.

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!