1. Anuncie Aqui ! Entre em contato fdantas@4each.com.br

I can't pass data to the component in Laravel

Discussão em 'Outras Linguagens' iniciado por el_codigo_me_encanta, Outubro 17, 2024 às 12:52.

  1. I'm trying to pass data to the components using directly to the Blade component (using @props).

    As a first step I put the following code in notification.blade.php:


    @props([
    'type' => 'info',
    'message'
    ])

    <div class="alert alert-{{ $type }} notification">
    {{ $message }}
    </div>

    Now in the test.blade.php view I put the following code (:type and :message are data passed to the component)


    <x-notification type="success" message="Success! Your changes have been saved" />

    <x-notification type="warning" message="Error! Something went wrong" />

    <x-notification :type="$type" :message="$message" />

    I get the following error:

    Undefined variable $message

    Can someone help me please?

    Continue reading...

Compartilhe esta Página