Y
Y
Yevhenii K2020-07-10 18:56:13
Laravel
Yevhenii K, 2020-07-10 18:56:13

Why does the @json directive pass incorrect data to an attribute?

When passing data to a Vue component using the @json directive, crookedly formatted data is displayed instead of the component. If used outside the attribute, the data is displayed normally, if the data is passed using the json_encode function, the component is displayed. What is the problem and how to fix it?
5f088e5ec7748390070372.png

<div class="x-content">
    <h1>Brands</h1>
    @json($brands)
    <hr>
    <p>Component</p>
    <v-brands-table :brands="@json($brands)"></v-brands-table>
    <hr>
    {{ json_encode($brands) }}
    <hr>
    <p>Component</p>
    <v-brands-table :brands="{{ json_encode($brands) }}"></v-brands-table>
</div>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
jazzus, 2020-07-10
@AFI19

:brands='@json($brands)'

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question