A
A
arseniylebedev2019-01-07 16:39:40
Laravel
arseniylebedev, 2019-01-07 16:39:40

How to pass array from blade to vue?

I send like this:

<servers-component :serversList="{{ json_encode($servers) }}"></servers-component>

If you look through the dev tools, then serverslist="[object Object]" is passed
And in the component itself, props serversList is undefined.
How to transfer data from laravel to vue normally?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
arseniylebedev, 2019-01-07
@arseniylebedev

<?php $sjson = json_encode($servers); ?>
 <servers-component :servers="{{ $sjson }}"></servers-component>

That's how it works. If you use {!! !!} then it doesn't work, the whole text of the object on the page is also half cut off.
I also understood why the data was not transferred to props with the name serversList. In html, you can’t call attributes like that, servers-list will be correct

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question