Using persistent layouts with composition api and <script setup> tag #481
Answered
by
rrrrando
rrrrando
asked this question in
Help (Vue)
-
Hi! I'm playing around with the new |
Beta Was this translation helpful? Give feedback.
Answered by
rrrrando
Mar 27, 2021
Replies: 2 comments
-
I read the RFC and figured it out. The solution is to just add a normal script tag like so : //Everything in here will be exposed to template
<script setup>
import Component from './ExampleCompoenent':
const item = "Some Vue stuff";
</script>
// Add a second script tag and export the layout
<script>
export default { layout: BlogLayout }
</script>
<template>
<p>Some content here! {{ item }}</p>
</template> |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
rrrrando
-
If you're using Vue 2.7 or Vue 3, you can alternatively use the defineOptions plugin to define a layout within <script setup>: <script setup>
import Layout from './Layout'
defineOptions({ layout: Layout })
</script> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I read the RFC and figured it out. The solution is to just add a normal script tag like so :