diff --git a/src/components/Tabs.vue b/src/components/Tabs.vue index b7f31be..db35db1 100644 --- a/src/components/Tabs.vue +++ b/src/components/Tabs.vue @@ -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: { @@ -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)) @@ -72,6 +79,10 @@ export default { } }, + mounted() { + if (this.hashTab) this.model = this.hashTab + }, + watch: { model() { this.$emit('input', this.model)