Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to change a layout dynamically? #175

Open
durbanitas opened this issue Nov 17, 2023 · 0 comments
Open

how to change a layout dynamically? #175

durbanitas opened this issue Nov 17, 2023 · 0 comments

Comments

@durbanitas
Copy link

durbanitas commented Nov 17, 2023

I need help using this line mentioned in the documentation on how to change a layout dynamically:

export default {
  layout: (ctx) => ctx.$device.isMobile ? 'mobile' : 'default'
}

Tried

index.vue

<script setup>
definePageMeta({
  layout: (ctx) => (ctx.$device.isMobile ? 'mobile' : 'default'),
});
</script>

<template>
  <main>
    ...
  </main>
</template>

Error

vite_ssr_import_6.default[props.name] is not a function

Invalid layout (ctx) => (ctx.$device.isMobile ? 'mobile' : 'default') selected.
[Vue warn]: Invalid prop: type check failed for prop "name". Expected String | Boolean, got Function

Question

Where do I place this? My guess is initalizing as a plugin or to create a middleware...

Goal

  • have two seperated layouts: default.vue and mobile.vue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants