Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using layout property in <script setup> tag

Is there any way to use layout property of inertiajs for vue 3 in <script setup> tag?

In other words, I am asking for an equivalent of the following code,

<script>
import from "../Shared/Layout";

export default {
   layout: Layout;
};
</script>

when the tag is the vue 3 <script setup>

Thank you

like image 942
Ayenew Yihune Avatar asked Aug 27 '26 16:08

Ayenew Yihune


1 Answers

If you or your tooling doesn't like there being two script tags, you can try this plugin for webpack that adds a macro that lets you use the Options API in your <script setup>

https://github.com/sxzz/unplugin-vue-define-options

In the case of Inertia.js layouts, it would look like this:

<script setup>
  import AppLayout from '@/Layouts/AppLayout';
  defineOptions({
    layout: AppLayout,
  });
</script>
like image 179
Brian Ortiz Avatar answered Aug 29 '26 12:08

Brian Ortiz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!