解决dvajs使用BrowserHistory路由模式后仍然会出现hash(哈希)

在dvajs中,如果你在初始化dva对象的时候不作任何处理,那么你就会发现即使你是用了BrowserRouter来作为Router url中也是会出现#/。解决方法也很简单:

  • 使用前先手动安装下 history 这个包:
$ npm install history --save
  • 修改 src/index.js 文件
import { createBrowserHistory as createHistory } from 'history';

const app = dva({
  history: createHistory()
});

参考:https://github.com/dvajs/dva/issues/1268
原文地址:https://www.cnblogs.com/axel10/p/9610910.html