I try to pass data from Laravel blade to Vue with props and I get undefined in console. I tried also
<example-component :course="{{ $course }}"></example-component>
<example-component course="{{!! $course !!}}"></example-component>
index.blade.php
@extends('layouts.app')
@section('content')
<div id="app">
</div>
<example-component course="{{ $course }}"></example-component>
<script src="{{asset('js/course/app.js')}}"></script>
@endsection
app.js
import { createApp } from 'vue';
import App from './components/App.vue'
import router from '../../router'
createApp(App).use(router).mount("#app")
App.vue
<template>
{{ course }}
</template>
<script>
export default {
props: ['course'],
mounted() {
console.log(this.course)
}
}
</script>
DOMContentLoaded
then it'll first wait for DOM to load then it'll not show any error in console. Have you tried something like that? – Hassaan Ali