Skip to content

Commit

Permalink
feat(#90): add loading tab by hash (#116)
Browse files Browse the repository at this point in the history
  • Loading branch information
Decipher authored Oct 13, 2023
1 parent de40a20 commit 7d6cf75
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/components/Tabs.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ import ThemeMixin from '../mixins/theme'
export default {
mixins: [ThemeMixin],
data: ({ tabs, tabId }) => ({
model: tabId(tabs[0]),
data: ({ hashTab, tabs, tabId }) => ({
model: hashTab || tabId(tabs[0]),
}),
props: {
Expand All @@ -58,6 +58,13 @@ export default {
},
},
computed: {
hashTab: ({ $route }) =>
$route.hash
? $route.hash.slice(1).split('-').slice(0, -1).join('-')
: undefined
},
methods: {
isSelected(tab, delta) {
return !!(this.model === this.tabId(tab, delta))
Expand All @@ -72,6 +79,10 @@ export default {
}
},
mounted() {
if (this.hashTab) this.model = this.hashTab
},
watch: {
model() {
this.$emit('input', this.model)
Expand Down

0 comments on commit 7d6cf75

Please sign in to comment.