Laravel Components Print Blank

Asked 2 years ago, Updated 2 years ago, 39 views

In Laravle 7,
in the output of the common display by the component. There will be extra spaces before and after the component display.

app/Views/Components/SiteTitle.php

class SiteTitle extensions Component
{

    public$title;
    
    /**
     * Create a new component instance.
     *
     * @return void
     */
    public function__construct()
    {
    $this->title='Title';
    }

    /**
     * Get the view/contents that present the component.
     *
     * @return\Illuminate\View\View|string
     */
    public function render()
    {
        return view('components.site-title');
    }
}

resources/views/components/site-title.blade.php

{{$title}}

displaying blade

<title><x-site-title/></title>

Simplified but
in the x-site-title portion in this configuration I'd like you to mark it as a title.

<title>Title>/title>

A blank space appears before and after the title, as shown in .

Does anyone know this solution?

laravel

2022-09-30 18:17

1 Answers

It didn't solve this problem, so I was able to implement similar functions with a helper, so I dealt with it.


2022-09-30 18:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.