2 years ago

Vue component inside a foreach loop

Posted 2 years ago by ekrist1

I´m building a multipage application and in some of my views I need some reactivity. One option I have thought about is to create a Vue component for each blade view, but it feels wrong.

If I have a blade view with a foreach loop of thousands of contacts (with pagination), is it considered a bad practise to add a component within the foreach loop?

@foreach($contacts as $contact)
{{ display something }}

I have started to understand and use some of the power with Vue and are using it for some part of my application, but sometimes it feels like going all in for Vue + Vue Routing or to use traditional blade with some jQuery scripts.

For instance:

Sometimes when you only need some reactivity to only one page and don´t need a reusable component it feel a bit wrong to create a global component.

Please sign in or create an account to participate in this conversation.