【发布时间】:2018-07-30 17:29:42
【问题描述】:
这篇文章是在link 发布的扩展。之前的问题解决了。
当我添加这条路线时,到目前为止一切正常。
<Route path="/resume-builder/display" component={ResumeDisplay} />
当我刷新此页面时,我可以通过项目中的另一个页面访问此页面,它显示错误
GET http://localhost:8080/resume-builder/dist/bundle.js 404 (Not Found)
display:1 Refused to execute script from 'http://localhost:8080/resume-builder/dist/bundle.js' because its MIME type ('text/html') is not executable, and strict MIME type checking is enabled.
我不知道为什么我的页面在 /resume-builder/dist/bundle.js 上寻找捆绑包,index.html 中明确提到它必须从中挑选捆绑包
<script src="./dist/bundle.js" ></script>
有没有人知道问题是什么?有什么办法可以解决这个问题?
【问题讨论】:
-
将脚本的源设置为“/dist/bundle.js”。这是您构建的捆绑包的绝对路径。目前它被设置为一个相对的。这意味着浏览器将尝试相对于当前 URl 路径解析它
-
已经一样了
-
不,不一样。你分享了@987654327@ 加入
index.html。更新到<script src="/dist/bundle.js"></script>还是有问题吗? -
是的,那件事奏效了。你能解释一下吗?
标签: javascript reactjs react-router-v4 react-router-dom