React-router not loading css for nested pages on refresh

后端 未结 7 497
甜味超标
甜味超标 2020-12-25 12:07

I\'m trying to setup a react-router for my first React webapp, it seems to be working except that the css doesn\'t load for my nested pages when I refresh the p

相关标签:
7条回答
  • 2020-12-25 12:50

    The simplest solution is here (Need to change index.html only)

    Just use %PUBLIC_URL% before every CSS or JS file.

    You can check an example of %PUBLIC_URL% in index.html file if you created react app through create-react-app.

    <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
    

    One thing is must: your CSS files and js files should be under a public directory.

    0 讨论(0)
提交回复
热议问题