【问题标题】:Use browser history admin-on-rest使用浏览器历史记录 admin-on-rest
【发布时间】:2017-02-28 06:43:59
【问题描述】:

我们可以在 admin-on-rest (React JS) 中使用浏览器历史记录而不是 hashhistory 吗? 我需要在 admin-on-rest 中更改某些内容还是只设置服务器来处理 URL?

【问题讨论】:

    标签: reactjs admin-on-rest


    【解决方案1】:

    显然现在只需从history 包创建浏览器历史实例并将其传递给<Admin /> 组件即可:

    import createHistory from 'history/createBrowserHistory';
    
    const history = createHistory();
    
    const App = () => (
        <Admin history={history}>
            ...
        </Admin>
    );
    

    根据documentation

    【讨论】:

    • 我这样做了,但我没有看到“历史”传播到子道具。我错过了什么?
    【解决方案2】:

    是的,您可以,但您需要编写自定义应用程序而不是使用&lt;Admin&gt; 组件。它记录在the official documentation

    【讨论】:

      猜你喜欢
      • 2015-06-14
      • 1970-01-01
      • 2010-10-20
      • 2012-07-22
      • 2011-11-14
      • 2013-05-21
      • 2011-02-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多