Using Vue component inside blade file with vitejs and laravel

Viewed 33

I'm a beginner in VueJS and I wonder how to use a vuejs component from my home.blade.php for example. Here is my code (I use ViteJS and not Mix)

Card.vue

<template>
    <h1>Hello world</h1>
    <p>Id : {{ filmId }}</p>
</template>

<script>
    export default {
        props: ['filmId']
    }
</script>

app.js

import './bootstrap';
import { createApp } from "vue";
import App from './App.vue';

createApp(App).mount('#app')

And my home.blade.php :

    <div id="app">

        <Card />

    </div>

    @vite('./resources/js/app.js')
1 Answers

You can't use vue components inside of blade files.

If you're using vue, you use vue for ALL of your views.

The only blade file would be your template which loads vue via vite.

Related