index.html与任何路由都不匹配 - react-router - react js

时间:2018-04-23 18:11:56

标签: javascript reactjs react-router

我很困惑。没有html-webpack-plugin插件,我可以运行我的项目,它工作正常:

yarn start

URL:

http://localhost:3000/

我的项目已经完成。现在我想构建我的项目,我想在服务器上传。

我的项目适用于Api。

现在,我想我应该使用html-webpack-plugin来获取构建文件。 为此,我运行此命令:

npm run build

并且它内部的dist目录是:

enter image description here

我在服务器上传了我的dist内容:

http://www.shadyab.com/test20/index.html

我在控制台上遇到了这个错误:

Warning: [react-router] Location "/test20/index.html" did not match any routes

整个我的项目:

https://github.com/smemamian/shadyab

1 个答案:

答案 0 :(得分:1)

您需要点击根网址,即/而不是index.html

http://www.shadyab.com/test20

如果要将/index.html映射到根网址,请在react-router中添加规则。

enter image description here

相关问题