【问题标题】:React deep/nested router not working when hosted on firebase托管在 Firebase 上时,React 深层/嵌套路由器无法正常工作
【发布时间】:2017-04-15 23:10:39
【问题描述】:

我已经检查了与我的这个问题相关的 stackoverflow,但没有一个解决它。

我正在为我的 reactJS 应用程序使用嵌套路由,该应用程序在我的本地 webpack 服务器上运行良好,但在 firebase 主机上运行良好。奇怪的是,它一直有效到 /admin/dashboard 路由,但任何其他路由都不起作用,即 /admin/list-bayaans/admin/listBayaans 它在浏览器控制台中显示错误 [no matching route found]。

Routes.js:

import React from 'react';
import {Route, IndexRoute, Link} from 'react-router';

import Layout from './components/layout';
import Homepage from './components/homepage';
import Bayaans from './components/bayaanspage';
import Readquran from './components/readquran';
import Duas from './components/duaspage';
import Events from './components/eventspage';
import Contactpage from './components/contact';

import AdminLayout from './components/admin/adminLayout';   // admin section (using same theme with little style variation)
import LoginPg from './components/admin/loginPage';
import Dashboard from './components/admin/dashboard';
import AdminBayaansPg from './components/admin/adminBayaansPage';
import AdminDuasPg from './components/admin/adminDuasPage';
import AdminEventsPg from './components/admin/adminEventsPage';

// we are defining 'home' route explicitly as an patch for now. So if user is on any innner page and he clicks the HOME menu then '/home' will render as '/' does not work and does nto return to the index page. Need to see it though.

export default (
            <div>
                 <Route path="/" component={Layout} >
                    <IndexRoute component={Homepage} />
                    <Route path="home" component={Homepage} />
                    <Route path="bayaans" component={Bayaans} />
                    <Route path="read-quran" component={Readquran} />
                    <Route path="duas" component={Duas} />
                    <Route path="events" component={Events} />
                    <Route path="contact" component={Contactpage} />
                 </Route>

                 <Route path="/admin" component={AdminLayout} >
                    <IndexRoute component={LoginPg} />
                    <Route path="dashboard" component={Dashboard} />
                    <Route path="list-bayaans" component={AdminBayaansPg} />
                    <Route path="list-duas" component={AdminDuasPg} />
                    <Route path="list-events" component={AdminEventsPg} />
                 </Route>
             </div>
);

问题:2 当我尝试通过使用firebase deploy 命令更改路由并在浏览器中签入时再次在firebase上部署时,路由保持不变。 (是的,我正在重新捆绑我的代码,然后进行部署。此外,正如我在问题一开始提到的那样,我只是在一条路线中进行小的文本更改只是为了调试。即 /list-bayaans/listBayaans

注意:我也检查了这个链接,但它不相关并且已经有这个链接中提到的内容:Trouble with deep routes on a single-page app on Firebase hosting

【问题讨论】:

    标签: reactjs firebase webpack react-router firebase-hosting


    【解决方案1】:

    它现在正在工作。基本上firebase 需要几分钟来加载新的部署更改(有时)。就我而言,大约需要 15 分钟。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-08-26
      • 2017-04-30
      • 2019-03-27
      • 2017-10-13
      • 1970-01-01
      • 2021-11-15
      • 2016-11-30
      • 1970-01-01
      相关资源
      最近更新 更多