后端django
前端ant design pro of vue
部署在apache上
监听两个端口
8000前端
8001后端
当8000监听到/api时转发到8001
yarn run serve时注销登录功能完好跳转至登录页
问题来了:
yarn build后首次点击注销登录功能可见刷新进度条但是是刷新的当前页没有跳转至登录页,再次点击注销登录,成功跳转至登录页
某种解决方案:
使用window.location.reload()
不使用this.$router.push({ name: ‘login’ })
大佬们带带我,我好端端写python的一个开发被这个问题困了两天,想不通想不通想不开
相关代码如下:
handleLogout (e) {
Modal.confirm({
title: this.$t(‘layouts.usermenu.dialog.title’),
content: this.$t(‘layouts.usermenu.dialog.content’),
onOk: () => {
// return new Promise((resolve, reject) => {
// setTimeout(Math.random() > 0.5 ? resolve : reject, 1500)
// }).catch(() => console.log(‘Oops errors!’))
return this.$store.dispatch(‘Logout’).then(() => {
this.$router.push({ name: ‘login’ })
})
},
onCancel () {}
})
export const constantRouterMap = [
{
path: ‘/user’,
component: UserLayout,
redirect: ‘/user/login’,
hidden: true,
children: [
{
path: ‘login’,
name: ‘login’,
component: () => import(/* webpackChunkName: “user” */ ‘@/views/user/Login’)
},
serve打印this.$router如下:
{…}
afterHooks: Array [ () ]
app: Object { _uid: 5, _isVue: true, “$options”: {…}, … }
apps: Array [ {…} ]
beforeHooks: Array [ () ]
fallback: false
history: {…}
base: “”
cb: function init()
current: Object { name: “login”, path: “/user/login”, fullPath: “/user/login”, … }
errorCbs: Array []
listeners: Array [ setupListeners() ]
pending: null
ready: true
readyCbs: Array []
readyErrorCbs: Array []
router: Object { app: {…}, fallback: false, mode: “hash”, … }
: Object { constructor: HashHistory(), setupListeners: setupListeners(), push: push(), … }
matcher: Object { match: match(), addRoutes: addRoutes() }
mode: “hash”
options: Object { mode: “hash”, routes: (2) […] }
resolveHooks: Array []
: Object { match: match(), init: init(), beforeEach: beforeEach(), … }
AvatarDropdown.vue:62
yarn build第一次点击注销登录打印this.$router如下:
{…}
afterHooks: Array [ 56d7() ]
app: Object { _uid: 5, _isVue: true, “$options”: {…}, … }
apps: Array [ {…} ]
beforeHooks: Array [ 56d7() ]
fallback: false
history: {…}
base: “”
cb: function init()
current: Object { name: “user”, path: “/personnel/user”, fullPath: “/personnel/user”, … }
errorCbs: Array []
pending: Object { name: “login”, path: “/user/login”, fullPath: “/user/login”, … }
ready: true
readyCbs: Array []
readyErrorCbs: Array []
router: Object { app: {…}, fallback: false, mode: “hash”, … }
: Object { constructor: e(), setupListeners: setupListeners(), push: push(), … }
matcher: Object { match: a(), addRoutes: addRoutes() }
mode: “hash”
options: Object { mode: “hash”, routes: (2) […] }
resolveHooks: Array []
: Object { match: match(), init: init(), beforeEach: beforeEach(), … }
app.574f5a29.js:1:32717
yarn build第二次点击注销登录打印this.$router如下:
{…}
afterHooks: Array [ 56d7() ]
app: Object { _uid: 5, _isVue: true, “$options”: {…}, … }
apps: Array [ {…} ]
beforeHooks: Array [ 56d7() ]
fallback: false
history: {…}
base: “”
cb: function init()
current: Object { name: “login”, path: “/user/login”, fullPath: “/user/login”, … }
errorCbs: Array []
pending: null
ready: true
readyCbs: Array []
readyErrorCbs: Array []
router: Object { app: {…}, fallback: false, mode: “hash”, … }
: Object { constructor: e(), setupListeners: setupListeners(), push: push(), … }
matcher: Object { match: a(), addRoutes: addRoutes() }
mode: “hash”
options: Object { mode: “hash”, routes: (2) […] }
resolveHooks: Array []
: Object { match: match(), init: init(), beforeEach: beforeEach(), … }
app.574f5a29.js:1:32717
观察到current和pending有所不同,第一次点击的时候push进去了但是没跳转,不知道怎么解决