react 路由 Hash history cannot PUSH the same path; a new entry will not be added to the history stack

 

 

react路由push的時候報警告如上解決辦法

原因是:當前路由下的 history 不能 push 相同的路徑到 stack 裏。

解決辦法,記錄下當前所有的路由history,當頁面跳轉的時候,如果是新路由直接跳轉 ,如果不是就去history裏面找到這個路由並跳轉

具體實現方法:

在項目的index.js(也就是項目的啓動頁)

import dva from 'dva';
import createHistory from 'history/createBrowserHistory'

const app = dva(
    {
        history: createHistory(),
        onError (error) {
          //message.error(error.message)
        },
    }
);

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章