鍍金池/ 問答/HTML/ 如何在本地配置roadhog刷新二級路由?

如何在本地配置roadhog刷新二級路由?

使用browserHistory后dva配置二級路由之后可以正常跳轉到二級路由,但是不能被刷新,刷新就會導致頁面變空白,我在網(wǎng)上找了解決辦法,都是以服務器配置去解決為主,我想在開發(fā)的時候就能夠刷新不變空白,不知道dva中的roadhog應該怎么配置
index.js使用
import createHistory from 'history/createBrowserHistory';
const app = dva({ history: createHistory() });

Main.js
class Main extends React.Component {

render() {
    return (
        <div>
            <div>
                <Link to='/first' >界面1</Link>&nbsp;&nbsp;&nbsp;<Link to='/second' >界面2</Link>
            </div>
            <div>
                <Route path="/" render={() => (
                    <div>
                        <Switch>
                            <Route path='/first' exact component={First} />
                            <Route path='/second' component={Second} />
                            <Route path='/first/three' component={Three} />
                        </Switch>
                    </div>
                )} />
            </div>
        </div>
    );
}

}

First.js
class First extends React.Component {

render() {
    return (
        <div>
            <Link to='/first/three'>跳轉到第三個界面</Link>
        </div>
    );
}

}

Second.js及Three.js
class Second extends React.Component{

render() {
    return(
        <div>第二個界面</div>
    );
}

}

clipboard.png

clipboard.png

clipboard.png

在到達/first/three這個地址之后,刷新該頁面

clipboard.png

頁面會消失,求指導

回答
編輯回答
陪妳哭

將你的二級目錄rewrite到index.html中。
配置proxy:

    "/first":{
      "target": "http://localhost:8000/",
      "pathRewrite": { "^/first.*$" : "/index.html" }
    },

建議你二級目錄給個統(tǒng)一的標識,比如: /main

2017年6月11日 16:58
編輯回答
冷溫柔

請問你解決了嘛?我也遇到這問題,問下你是怎么解決的呀

2018年6月27日 13:50