刷新反应子页面时找不到页面消失

时间:2018-08-13 10:47:10

标签: javascript reactjs

我使用的是React Router,我将自己的项目构建到了虚拟主机上,当我进入某个子页面并刷新它时,找不到页面消失了。

import React from 'react';
import ReactDOM from 'react-dom';
import{ BrowserRouter as Router, Route, Link, BrowserRouter} from 
'react-router-dom';

import App from './App';
import registerServiceWorker from './registerServiceWorker';

ReactDOM.render(<Router ><App /></Router>, 
document.getElementById('root'));
registerServiceWorker();

这是我的app.js的样子:

        <div className="App" >


        <Header  />

        <Route exact path="/" component={Homepage} />
        <Route exact path='/Kontakt' component={Kontakt}/>
        <Route  path='/Kontaktformular' component={Kontaktformular} />
        <Route  path='/Agatoveihriska' component={Agatoveihriska} />
        <Route  path='/Fitnessworkout' component={Fitnessworkout} />
        <Route  path='/Referencie' component={Referencie} />
        <Route  path='/Hraciezostavy' component={Hraciezostavy} />
        <Route  path='/Domcekyaltanky' component={Domcekyaltanky} />
        <Route  path='/Hojdackylavice' component={Hojdackylavice} />


        { window.location.pathname === "/" || window.location.pathname === "/Kontakt" ? null : <Kontaktformular /> }


    </div>

0 个答案:

没有答案