Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'match' of undefined #19

Closed
abinnz opened this issue Oct 24, 2020 · 1 comment
Closed

Cannot read property 'match' of undefined #19

abinnz opened this issue Oct 24, 2020 · 1 comment

Comments

@abinnz
Copy link
Contributor

abinnz commented Oct 24, 2020

debug发现keep的数据有些偏差,run.location_country可能为"None"值的情况,导致出现下述错误:

TypeError: Cannot read property 'match' of undefined
locationForRun
D:/github/running_page/src/utils/utils.js:49
  46 | }
  47 | const l = location.split(',');
  48 | // or to handle keep location format
> 49 | const countryMatch = l[l.length - 1].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/) || l[2].match(/[\u4e00-\u9fa5].*[\u4e00-\u9fa5]/);
  50 | if (countryMatch) {
  51 |   [country] = countryMatch;
  52 | }
  
 D:/github/running_page/src/pages/index.jsx:29
  26 | const locationsList = [];
  27 | runs.forEach(
  28 |   (run) => {
> 29 |     const location = locationForRun(run);
  30 |     const periodName = titleForRun(run);
  31 |     if (periodName) {
  32 |       runPeriod[periodName] = runPeriod[periodName] === undefined ? 1 : runPeriod[periodName] + 1;
@yihong0618
Copy link
Owner

收到。我晚上看一下,谢谢反馈,如果你想快速解决的话,可以 if 判断一下~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants