panthro
panthro

Reputation: 24061

Using Laravel includes inside a vue component?

I have a set of components, some components include other components via @include('my-sub-component')

The issue is that when I want to use vue I have to put the entire component in the vue.js file inside the template tags.

But inside the template I want to use the @include so I can include some sub components. This does not work.

How can I include blade components inside a vue component?

Upvotes: 3

Views: 4543

Answers (2)

Erik Berkun-Drevnig
Erik Berkun-Drevnig

Reputation: 2356

The closest thing you can get to this is to use inline templates. You can't access blade directives it if you are writing your templates in single file components and compiling them with webpack or something because they are not being rendered with PHP.

You could put the style and scripts components in the SFC though and but in order to use blade directives the template would need to be in a .blade.php file

Upvotes: 0

nmfzone
nmfzone

Reputation: 2903

As far as I know, it's impossible. You can't use PHP (Laravel Blade) .blade.php tags inside Vue Component .js, of course Vue can't execute PHP script in this case. The possible use case is you use the Vue Component inside Laravel Blade.

Upvotes: 3

Related Questions