I've built a few sites using Laravel (love it)...All laracasts lessons seems to be aimed at using vue to drive the frontend OR blade, but not really both in a real-world way IMHO.
My current project outputs blade/html and uses a wee bit of javascript here-and-there for stuff like form checking/ ajax loading, etc. [not a SPA]
What I can't wrap my head around is how to combine Vue with Blade in an organized, DRY way.
In the past I've just thrown the javascript at the bottom of the Blade template. It works with all kinds of Vue warnings and doesn't feel right:
...html...
</div>
<script type="text/javascript">
var app = new Vue({
el: '#app',
data: {
cms_icon: {
wordpress: 'fab fa-wordpress-simple',
joomla: 'fab fa-joomla',
drupal: 'fab fa-drupal',
shopify: 'fab fa-shopify',
other: 'fas fa-wrench',
},
},
methods: {
}
});
</script>
Where do I put each page's Vue/javascript?
I know about Vue's Single File Components but that seems like a solution for a js-driven site (one in which every page pulls its content via ajax). I'm interested in leveraging mostly blade's @foreach and other control statements. If I move the html over to a Vue Single File Component...then I have to pass in php variables into Vue and then render it out. Not really what I want to do.
I want to render most pages with blade/php and use Vue to handle small tasks, like applying icons. Showing content when clicking, etc.... (all that standard stuff us old timers used to use jquery to do!)
How do I structure this?
thank you