• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

跳转到当前路由的时候,vue的出错解决方案

互联网 diligentman 4天前 6次浏览

跳转到当前路由的时候,vue的出错解决方案

import Vue from 'vue'
import VueRouter from 'vue-router'
Vue.use(VueRouter)
// 解决跳转到当前路由的时候,控制台报错
// const originalPush = VueRouter.prototype.push
// VueRouter.prototype.push = function push(location) {
//     return originalPush.call(this, location).catch(err => err)
// }
const routes = [{
        path: '/',
 name: 'index',
 component: () =>
            import ('./../views/home/index')
    },
 {
        path: '/movie',
 name: '/movie',
 component: () =>
            import ('./../views/movie/index')
    },
 {
        path: '/birth',
 name: '/birth',
 component: () =>
            import ('./../views/birth/index')
    },
 {
        path: '/Lifemeeting',
 name: '/Lifemeeting',
 component: () =>
            import ('./../views/Lifemeeting/Lifemeeting')
    },
 {
        path: '/Sign',
 name: '/Sign',
 component: () =>
            import ('./../views/UserInformation/Sign.vue')
    },
]
const router = new VueRouter({
    mode: 'history',
 base: process.env.BASE_URL,
 routes
})
//
// router.beforeEach((from,to,next)=>{
// console.log('from',from)
// console.log('to',to)
//     next()
// })
export default router

喜欢 (0)