-
-
Save andrejsharapov/745d47800ff3eb9d57a8c0d735edee84 to your computer and use it in GitHub Desktop.
vue component switcher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <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