vue中路由跳轉報錯

Error: Avoided redundant navigation to current location: "/X".

解決:在router文件夾下的index.js中加入代碼:

import Vue from 'vue'
import Router from 'vue-router'
import Chat from '../components/Chat.vue'
import User from '../components/User.vue'
import Find from '../components/Find.vue'
import My from '../components/My.vue'

Vue.use(Router)

export default new Router({
  routes: [
    {
      path: '/',
      component: Chat
    },
    {
      path: '/User',
      component: User
    },
    {
      path: '/Find',
      component: Find
    },
    {
      path: '/My',
      component: My
    }
  ]
})

// 解決報錯的代碼
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
}
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章