From beb97421d7ad316e8a90a08bab5819635c0b1446 Mon Sep 17 00:00:00 2001 From: Yale Date: Wed, 1 Sep 2021 14:29:43 +0800 Subject: [PATCH] Update index.vue fix use `this.$store this.$router this.$route` error in setup function with Vue3.0 --- src/layout/vab-avatar/index.vue | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/layout/vab-avatar/index.vue b/src/layout/vab-avatar/index.vue index 8e15d23..be50e2e 100644 --- a/src/layout/vab-avatar/index.vue +++ b/src/layout/vab-avatar/index.vue @@ -22,20 +22,23 @@ import { useStore } from 'vuex' import { computed } from 'vue' + import { useRoute, useRouter } from 'vue-router' export default { name: 'VabAvatar', components: { DownOutlined }, setup() { const store = useStore() - + const router = useRouter(); + const route = useRoute(); + const logout = async () => { - await this.$store.dispatch('user/logout') + await store.dispatch('user/logout') if (recordRoute) { - const fullPath = this.$route.fullPath - this.$router.push(`/login?redirect=${fullPath}`) + const fullPath = route.fullPath + router.push(`/login?redirect=${fullPath}`) } else { - this.$router.push('/login') + router.push('/login') } }