diff --git a/src/permission.js b/src/permission.js index 750aeab6..5b0a6ed4 100644 --- a/src/permission.js +++ b/src/permission.js @@ -11,6 +11,12 @@ NProgress.configure({ showSpinner: false }) // NProgress Configuration const whiteList = ['/login', '/auth-redirect'] // no redirect whitelist router.beforeEach(async(to, from, next) => { + // skip some code, make tab work with router smoother + if (to.path === from.path) { + next() + return + } + // start progress bar NProgress.start() diff --git a/src/views/tab/index.vue b/src/views/tab/index.vue index 6438a47a..f07a99f9 100644 --- a/src/views/tab/index.vue +++ b/src/views/tab/index.vue @@ -26,20 +26,18 @@ export default { { label: 'Japan', key: 'JP' }, { label: 'Eurozone', key: 'EU' } ], - activeName: 'CN', createdTimes: 0 } }, - watch: { - activeName(val) { - this.$router.push(`${this.$route.path}?tab=${val}`) - } - }, - created() { - // init the default selected tab - const tab = this.$route.query.tab - if (tab) { - this.activeName = tab + computed: { + activeName: { + get() { + return this.$route.query.tab || 'CN' + }, + set(tab) { + // this.$router.push({ query: { tab }}) + this.$router.replace({ query: { tab }}) + } } }, methods: {