Reactjs React应用程序在本地主机上工作,但在github或heroku上部署时出现错误。部署时没有错误
我创建了一个react应用程序来显示不同国家的电晕感染情况。这在我的本地主机上工作,但当我在github或heroku上部署它时,会生成一个错误。以下错误在blockquote中给出。当我检查文件country.js时查看错误,没有n[0]。下面的“请帮助”是指向托管应用程序和该应用程序的github存储库的链接 TypeError:“n[0]未定义” E country.js:13 E country.js:11 反应7 不稳定的_runWithPriority scheduler.production.min.js:19 反应6 a App.js:22 u runtime.js:45 _调用runtime.js:274 t runtime.js:97 r asyncToGenerator.js:3 asyncToGenerator.js:25 react dom.production.min.js:209:194 反应5 不稳定的_runWithPriority scheduler.production.min.js:19 反应4 不稳定的_runWithPriority scheduler.production.min.js:19 反应6 a App.js:22 u runtime.js:45 _调用runtime.js:274 t runtime.js:97 r asyncToGenerator.js:3 asyncToGenerator.js:25 TypeError:n[0]未定义 country.js:13:30 和Reactjs React应用程序在本地主机上工作,但在github或heroku上部署时出现错误。部署时没有错误,reactjs,heroku,web-deployment,Reactjs,Heroku,Web Deployment,我创建了一个react应用程序来显示不同国家的电晕感染情况。这在我的本地主机上工作,但当我在github或heroku上部署它时,会生成一个错误。以下错误在blockquote中给出。当我检查文件country.js时查看错误,没有n[0]。下面的“请帮助”是指向托管应用程序和该应用程序的github存储库的链接 TypeError:“n[0]未定义” E country.js:13 E country.js:11 反应7 不稳定的_runWithPriority scheduler.produ
我已检查了您的站点,发现以下错误:
react_devtools_backend.js:6 TypeError: Cannot read property 'Afghanistan' of undefined
at country.js:13
at Array.map (<anonymous>)
at E (country.js:11)
at Ki (react-dom.production.min.js:153)
at Fo (react-dom.production.min.js:175)
at va (react-dom.production.min.js:263)
at cu (react-dom.production.min.js:246)
at au (react-dom.production.min.js:246)
at Za (react-dom.production.min.js:239)
at react-dom.production.min.js:123
react\u devtools\u backend.js:6类型错误:无法读取未定义的属性“Afghanistan”
在country.js:13
在Array.map()处
在E(country.js:11)
在Ki(react dom.production.min.js:153)
在Fo(react dom.production.min.js:175)
在弗吉尼亚州(react dom.production.min.js:263)
在cu(react dom.production.min.js:246)
在au(react dom.production.min.js:246)
在Za(react dom.production.min.js:239)
在react dom.production.min.js:123
因此,您必须共享该文件的代码。因为它给出了一个TypeError。为了解决这个问题,,
您可以从更改country.js
中的代码
const countryflag = Object.keys(data).map((name) => {
return data[name][0];
})
到
并直接以这种方式使用它:
${countryflag[country[0]]}
错误-无法读取未定义的属性“Afghanistan”。问题中给出了github存储库的Country.js第13行链接,()是Country.js的链接当我在本地主机上运行它时,它在我的电脑上运行正常,但当它部署在github上时,它工作不正常,并且正在生成错误。
${countryflag[country[0]]}