为什么React-Router SetRouteleavehook断开了索引链接



问题:如果我添加router.setRouteleavehook((或router.listenbefore((到我的组件中,它将破坏徽标homepage链接到路径="/"

详细信息:我想创建"请假确认"。这是我的组件代码。(包装(

componentDidMount() {
  this.props.router.setRouteLeaveHook(this.props.route, this.routerWillLeave);
},
routerWillLeave(nextLocation) {
    return 'Are you sure you want to leave?';
}

我的问题是当我单击链接或indexlink(路径='/'(并确认过渡时,我有错误:

Uncaught DOMException: Failed to execute 'pushState' on 'History': A history state object with URL 'http:' cannot be created in a document with origin 'http://mydomain.dev' and URL 'http://mydomain.dev/user/services'.

调试:发现在lib/createBrowserhistory.js中是此函数调用

window.history.pushState(historyState, null, path);

路径为//而不是预期/。(位置对象具有基础'/'和路径'/'(

版本: react@15.4.1,react-router@2.8.1,history@2.1.2

路由器basename是错误的。"/"而不是"。

最新更新