Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

【Bug】import { browserHistory } from 'dva/router'; 中 browserHistory 测试仍为 hashHistory #1268

Closed
dkvirus opened this issue Oct 10, 2017 · 5 comments

Comments

@dkvirus
Copy link

dkvirus commented Oct 10, 2017

Code to reproduce the issue: (请提供可复现的代码或者步骤)

dva v2.0.3 中想使用 browserHistory,在 dva API 中写法如下,但实际测试中 history 仍问 hashHistory。浏览器中输入这个地址才能正常显示:http://localhost:8000/#/products

import { browserHistory } from 'dva/router';
const app = dva({
  history: browserHistory,
});

Expected behavior: (预期的正常效果)

预期通过 import { browserHistory } from 'dva/router'; 导入的 browserHistory 是浏览器 history

Actual behavior: (实际效果)

通过 import { browserHistory } from 'dva/router'; 导入的 browserHistory 实际测试是 hashHistory

Versions of packages used: (哪个库的哪个版本出现的问题)

dva版本: v2.0.3

@dkvirus dkvirus closed this as completed Oct 10, 2017
@masogit
Copy link

masogit commented Oct 13, 2017

@dkvirus 此问题如何解决的?

@dkvirus
Copy link
Author

dkvirus commented Oct 16, 2017

@masogit 目前这个 bug 好像还未修复,我采用替代方案是 history 第三方库。

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

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

@zjxpcyc
Copy link

zjxpcyc commented Oct 16, 2017

参考这个 8480aac

@smoothdvd
Copy link

奇怪,我在index.js中删除了history: browserHistory, 然后在router.js使用history包,不起作用。一定要在index.js里才行。

@linShirly
Copy link

使用此方法后 单层路由可以访问了 但是多层路由好像就访问不了了 类似/order/news 这样的路由就访问不到了 请问是什么原因呢

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants