Dva: 如何设置basename

Created on 5 Jul 2017  ·  5Comments  ·  Source: dvajs/dva

没使用dva之前是这样用的。

import { createHistory } from 'history'
import { useRouterHistory } from 'react-router'
import { syncHistoryWithStore } from 'react-router-redux'

const browserHistory = useRouterHistory(createHistory)({
  basename: '<yourBaseUrl>'
})
const history = syncHistoryWithStore(browserHistory, store)

现在应该如何配置呢?

question

All 5 comments

试试这样:

import { createHistory } from 'history'
import { useRouterHistory } from 'dva/router'

const browserHistory = useRouterHistory(createHistory)({
  basename: '<yourBaseUrl>'
})
const app = dva({
  history: browserHistory,
});

检查下为啥 index.js 没访问到吧,这是 fallback 到 index.html 的内容了。

不好意思,刚刚这个描述有点误导性。等下我会把遇到的问题重新描述一下。

现在还是会跳转到/login, 但预期的是跳转到<basename>/login

如果能做到基于相对路径跳转也可以。

Was this page helpful?
0 / 5 - 0 ratings