Skip to content

Instantly share code, notes, and snippets.

@andrejsharapov
Created September 17, 2024 07:24
Show Gist options
  • Select an option

  • Save andrejsharapov/745d47800ff3eb9d57a8c0d735edee84 to your computer and use it in GitHub Desktop.

Select an option

Save andrejsharapov/745d47800ff3eb9d57a8c0d735edee84 to your computer and use it in GitHub Desktop.
vue component switcher
<template>
<v-card>
<div v-if="!currentTab">
...
</div>
<component v-else :is="currentTabComponent" />
</v-card>
<v-row class="d-flex align-center">
<v-col v-for="tab in games" :key="tab.name">
<v-item v-slot="{ active, toggle }">
<v-card>
<v-card @click="toggle; currentTab = tab;">
<v-scroll-y-transition>
<h3 class="font-weight-light">{{ tab.name }}</h3>
</v-scroll-y-transition>
</v-card>
</v-card>
</v-item>
</v-col>
</v-row>
</template>
<script>
const One = () => import('~/components/...');
const Two = () => import('~/components/...');
const Three = () => import('~/components/...');
export default {
data: () => ({
currentTab: null,
games: [
{ name: 'one', component: One },
{ name: 'two', component: Two },
{ name: 'three', component: Three },
],
}),
computed: {
currentTabComponent() {
return this.currentTab?.component;
},
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment