Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/logging/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 动态反应路线';无法正确加载css?_Javascript_Html_Css_Reactjs_React Router - Fatal编程技术网

Javascript 动态反应路线';无法正确加载css?

Javascript 动态反应路线';无法正确加载css?,javascript,html,css,reactjs,react-router,Javascript,Html,Css,Reactjs,React Router,我为localhost设置了一个路由:8080/song/9,其中9是动态加载页面的任意数字。这是我应用程序中唯一一种当我检查stylesheet.css时完全为空的路由类型。它成功地加载了它,但由于某种原因它是空的 如果我转到任何其他路径,它都会成功加载,这使我相信它与react中的动态路由有关。这是我为路线设置的代码 return ( <div className="container-fluid"> <Router>

我为localhost设置了一个路由:8080/song/9,其中9是动态加载页面的任意数字。这是我应用程序中唯一一种当我检查stylesheet.css时完全为空的路由类型。它成功地加载了它,但由于某种原因它是空的

如果我转到任何其他路径,它都会成功加载,这使我相信它与react中的动态路由有关。这是我为路线设置的代码

return (
        <div className="container-fluid">
            <Router>
                <div>
                    <Route exact = {true} path={"/" } component = {Home}/>
                    <Route exact = {true} path={"/login"} component = {Login}/>
                    <Route exact = {true} path={"/register"} component ={Register}/>
                    <Route exact = {true} path={"/song/:songId"} component={SongEditor}/>
                    <Route exact = {true} path={"/create"} component={CreateSong}/>

                </div>
            </Router>

        </div>
    );
返回(
);

我也尝试过将/song/songId路径的exact设置为false,但我仍然存在问题

如果您的样式表像
href=“style.css”
一样链接,将文档位置更改为
localhost:8080/song/9
将使浏览器在
localhost:8080/song/style.css
中查找它。您可以通过将其更改为
href=“/style.css”
@ChrisG href=“./css/stylesheet.css”以href=“/css/stylesheet.css”来纠正此问题!!!谢谢。如果你想把它作为一个答案,我会为你接受你的问题是重复的:并且很可能会被标记和删除可能的重复