Support the ongoing development of Laravel.io →
Jetstream Vue.js Laravel
Last updated by @novica89 1 year ago.
0

Never mind, seems like you can just use regular options API approach straight away instead of composition. The only thing is: You have to import "Layout" component(s) inside of the <script setup></script> tags and can't do it the "usual" way by importing in the regular script tags (where you define component object, import other components that you might be using etc). So, an example of the default "Dashboard" component in Inertia but re-written in Options API would be this:

<template>
    <AppLayout title="Dashboard">
        <template #header>
            <h2 class="font-semibold text-xl text-gray-800 leading-tight">
                {{ title }}
            </h2>
        </template>

        <div class="py-12">
            <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
                <div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
                    {{ content }}
                    <Welcome />
                </div>
            </div>
        </div>

    </AppLayout>
</template>

<script setup>
// Layout's HAVE TO be imported in the script setup
import AppLayout from '@/Layouts/AppLayout.vue';
</script>

<script>
// Other components used can just be imported the usual way
import Welcome from '@/Components/Welcome.vue';

export default {
    // I directly send properties from backend and they get populated in as props
    props: {
        title: String,
        content: String
    },
};
</script>

If anyone knows the way around having to import layout file in the setup script tag, let me know.

Last updated 1 year ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Novica novica89 Joined 15 Feb 2023

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.