Answer the question
In order to leave comments, you need to log in
What is the best way to pass large collections of data from Laravel to Vue.js?
For example, there are 8k users, how best to transfer them to the view, I tried it as props, but it just doesn’t work, it says that the collection is empty, I suspect that it doesn’t have time to process the props.
Is it better to get a query on the apishka when the view is created?
What other options are there?
Answer the question
In order to leave comments, you need to log in
You can create a global variable or function in the page code that will return an array of users.
users/show.blade.php
<script>
function getMyUsers() { return @json($arrayOfUsers); }
</script>
...
<script>
const vm = new Vue({
data: function() {
return {
users: getMyUsers(),
counter: 0,
};
}
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question