解決dvajs使用BrowserHistory路由模式後仍然會出現hash(哈希)

在dvajs中,若是你在初始化dva對象的時候不做任何處理,那麼你就會發現即便你是用了BrowserRouter來做爲Router url中也是會出現#/。解決方法也很簡單:git

  • 使用前先手動安裝下 history 這個包:
$ npm install history --save
  • 修改 src/index.js 文件


參考:https://github.com/dvajs/dva/issues/1268import { createBrowserHistory as createHistory } from 'history'; const app = dva({ history: createHistory() });
相關文章
相關標籤/搜索