Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
916 views
in Technique[技术] by (71.8m points)

vue.js - app.js:51471 Uncaught (in promise) Error: Navigation cancelled from "/customer/login" to "/customer/dashboard" with a new navigation

I am using router push to redirect on other page after login but it is giving me this error

app.js:51471 Uncaught (in promise) Error: Navigation cancelled from "/customer/login" to "/customer/dashboard" with a new navigation.

from login page when customer logged in successfully I am pushing to next route like this

router.push(router.currentRoute.query.to || '/customer/dashboard')

I don't know where it goes wrong.

Here is route in router.js

if(!store.state.AppActiveUser.is_customer){
        if (!to.meta.authRequired && auth.isAuthenticated()) {
            router.push({ path: '/dashboard', name: 'dashboard', component: './views/DashboardAnalytics.vue' })
        }
    }else{
    if (!to.meta.authRequired && auth.isAuthenticated()) {
        router.push({ path: '/customer/dashboard', name: 'customer-dashboard', component: '@/views/apps/customerComponents/dashboard/DashboardAnalytics.vue' })
    }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You have to catch such errors with a catch branch to router.push()

router.push({ 
  path: '/customer/dashboard', 
  name: 'customer-dashboard', 
  component: '@/views/apps/customerComponents/dashboard/DashboardAnalytics.vue' 
})
.catch(() => true);

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...