Update index.vue

fix use `this.$store this.$router  this.$route`  error  in setup function with Vue3.0
This commit is contained in:
Yale 2021-09-01 14:29:43 +08:00 committed by GitHub
parent e934394182
commit beb97421d7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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')
}
}