@larissa
To use a Vue.js component in a Laravel Blade template, you can follow these steps:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
// MyComponent.vue <template> <div> <h1>{{ message }}</h1> </div> </template> <script> export default { data() { return { message: 'Hello from Vue component!' }; } }; </script> |
1 2 3 4 5 6 |
// YourBladeTemplate.blade.php <div id="app"> <my-component></my-component> </div> <script src="{{ mix('js/app.js') }}"></script> |
1 2 3 4 5 6 7 8 9 10 |
// app.js import Vue from 'vue'; import MyComponent from './components/MyComponent.vue'; new Vue({ el: '#app', components: { 'my-component': MyComponent } }); |
Now, you should be able to see the Vue.js component rendered in your Laravel Blade template.
Note: Make sure to compile the Vue component whenever you make changes to it, and don't forget to include the necessary JavaScript files in your Blade template.