import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home/Home.vue'
import Recommend from '../views/Recommend/Recommend.vue'
import Me from '../views/Me/Me.vue'
import Chat from '../views/Chat/Chat.vue'
import Search from '../views/Search/Search.vue'
// 这里按照网上的方法加入了以下代码,但是还是不管用
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location)?{
return originalPush.call(this, location).catch(err => err)
}
Vue.use(VueRouter)
const routes =?[
{
path: '/',
redirect: '/home'
},
{
path: '/home',
component: Home,
children: [
{ path: '/recommend', component: Recommend },
{ path: '/search', component: Search },
{ path: '/me', component: Me },
{ path: '/chat', component: Chat }
]
}
]
const router = new VueRouter({
routes
})
export default router
这是我的代码,我在按照网上提示,加入了
`const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push (location)?{
return originalPush.call(this, location).catch(err => err)
}`
但是还是报一样的错误,是我加点位置有问题吗?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…