question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

defineNuxtComponent doesn't support layout property

See original GitHub issue

Environment

  • Operating System: Darwin
  • Node Version: v16.17.1
  • Nuxt Version: 3.0.0-rc.13
  • Nitro Version: 0.6.1
  • Package Manager: yarn@1.22.19
  • Builder: vite
  • User Config: ssr, build, modules, buildModules
  • Runtime Modules: @formkit/nuxt@1.0.0-beta.11
  • Build Modules: @nuxtjs/tailwindcss@6.1.3, @nuxtjs/eslint-module@3.1.0

Reproduction

Try using different layout on the page:

<script lang="ts">
export default defineNuxtComponent({
  layout: 'admin',
})
</script>

Describe the bug

Hi, I’m migrating the project on options API to Nuxt 3, and looks like layout option doesn’t work when using options API.

Additional context

No response

Logs

No response

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
danielroecommented, Nov 6, 2022

The current difference is support for Options API-style asyncData: see https://v3.nuxtjs.org/api/utils/define-nuxt-component.

1reaction
danielroecommented, Nov 4, 2022

Try this:

<script lang="ts">
definePageMeta({
  layout: 'admin'
})

export default defineComponent({
})
</script>

A PR to improve docs would be welcome 🙏

Read more comments on GitHub >

github_iconTop Results From Across the Web

Layouts directory - Nuxt
Every file (top-level) in the layouts directory will create a custom layout accessible with the layout property in the page components. Let's say...
Read more >
Nuxt.js default layout not being applied - Stack Overflow
I'm brand new to using Nuxt.js, and having an issue: When I created my project, the layouts folder wasn't generated automatically as documented ......
Read more >
layouts/ · Nuxt Directory Structure
Unlike other components, your layouts must have a single root element to allow Nuxt to apply transitions between layout changes - and this...
Read more >
Views - NuxtJS
Info: Make sure to add the <nuxt/> component when creating a layout to ... a custom layout accessible with the layout property in...
Read more >
Views - Nuxt.js
Every file (top-level) in the layouts directory will create a custom layout accessible with the layout property in the page components. Let's say...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found