remove extra hash changed event

This commit is contained in:
Westly Wright 2020-07-06 14:11:30 -07:00
parent 2164ca4e53
commit 95d313e578
No known key found for this signature in database
GPG Key ID: 4FAB3D8673DC54A3
1 changed files with 30 additions and 34 deletions

View File

@ -25,10 +25,6 @@ export default {
},
watch: {
'$route.hash'() {
this.hashChange();
},
sortedTabs(tabs) {
const {
defaultTab,
@ -53,38 +49,38 @@ export default {
},
},
created() {
const {
$children,
$route: { hash },
defaultTab,
sortedTabs,
} = this;
this.tabs = $children;
let tab;
const selected = (hash || '').replace(/^#/, '');
if ( selected ) {
tab = this.find(selected);
}
if ( !tab ) {
tab = this.find(defaultTab);
}
if ( !tab ) {
tab = head(sortedTabs);
}
if ( tab ) {
this.select(tab.name);
}
},
mounted() {
window.addEventListener('hashchange', this.hashChange);
this.$nextTick(() => {
const {
$children,
$route: { hash },
defaultTab,
sortedTabs,
} = this;
this.tabs = $children;
let tab;
const selected = (hash || '').replace(/^#/, '');
if ( selected ) {
tab = this.find(selected);
}
if ( !tab ) {
tab = this.find(defaultTab);
}
if ( !tab ) {
tab = head(sortedTabs);
}
if ( tab ) {
this.select(tab.name);
}
});
},
unmounted() {