<i id='VCGQJ'><tr id='VCGQJ'><dt id='VCGQJ'><q id='VCGQJ'><span id='VCGQJ'><b id='VCGQJ'><form id='VCGQJ'><ins id='VCGQJ'></ins><ul id='VCGQJ'></ul><sub id='VCGQJ'></sub></form><legend id='VCGQJ'></legend><bdo id='VCGQJ'><pre id='VCGQJ'><center id='VCGQJ'></center></pre></bdo></b><th id='VCGQJ'></th></span></q></dt></tr></i><div id='VCGQJ'><tfoot id='VCGQJ'></tfoot><dl id='VCGQJ'><fieldset id='VCGQJ'></fieldset></dl></div>

      1. <tfoot id='VCGQJ'></tfoot>
      2. <legend id='VCGQJ'><style id='VCGQJ'><dir id='VCGQJ'><q id='VCGQJ'></q></dir></style></legend>
          <bdo id='VCGQJ'></bdo><ul id='VCGQJ'></ul>

        <small id='VCGQJ'></small><noframes id='VCGQJ'>

        无法读取未定义错误的属性“匹配"

        Cannot read property #39;match#39; of undefined error(无法读取未定义错误的属性“匹配)

        <i id='G8AVW'><tr id='G8AVW'><dt id='G8AVW'><q id='G8AVW'><span id='G8AVW'><b id='G8AVW'><form id='G8AVW'><ins id='G8AVW'></ins><ul id='G8AVW'></ul><sub id='G8AVW'></sub></form><legend id='G8AVW'></legend><bdo id='G8AVW'><pre id='G8AVW'><center id='G8AVW'></center></pre></bdo></b><th id='G8AVW'></th></span></q></dt></tr></i><div id='G8AVW'><tfoot id='G8AVW'></tfoot><dl id='G8AVW'><fieldset id='G8AVW'></fieldset></dl></div>

        1. <legend id='G8AVW'><style id='G8AVW'><dir id='G8AVW'><q id='G8AVW'></q></dir></style></legend>
            <tbody id='G8AVW'></tbody>
              <bdo id='G8AVW'></bdo><ul id='G8AVW'></ul>
            • <tfoot id='G8AVW'></tfoot>

              • <small id='G8AVW'></small><noframes id='G8AVW'>

                  本文介绍了无法读取未定义错误的属性“匹配"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我试图在 React JS 前端显示一些文本来代替配置文件图像,当它不可用时.基本上,我将当前客户名称传递给一个函数,该函数提取名称中所有单词的第一个字符.我能够只显示名称,但是当我执行函数调用时,我收到无法读取未定义的属性匹配"错误并且页面未呈现.Console.log() 显示未定义.

                  I am trying to display some text in React JS frontend in place of a profile image when it isn't available.Basically, I pass the current customer name to a function which extracts the first characters of all the words in the name. I am able to display just the name but when I do a function call, I get Cannot read property 'match' of undefined" error and the page does not render. Console.log() displays undefined.

                  HTML:

                  <li className="nav-item">
                  
                                 <div id="container_acronym">
                                   <div id="name_acronym">                        
                                      {this.acronym_name(this.state.lead_details.customer_name)}
                                   </div>
                                  </div>                 
                          </li>
                  

                  JS:

                  acronym_name(str){
                  var regular_ex=/(w)/g;
                  var matches = str.match(regular_ex);
                  var acronym = matches.join('');
                  document.getElementById("name_acronym").innerHTML = acronym;
                  }
                  

                  推荐答案

                   acronym_name(str){
                  
                          if (typeof str == 'undefined') {   
                              str = '';
                          }
                          else{ 
                              var regular_ex=/(w)/g;
                              var matches = str.match(regular_ex);
                              var acronym = matches.join('');
                              return acronym;
                  
                          }
                      }
                  

                  这篇关于无法读取未定义错误的属性“匹配"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Pause youtube video, youtube api(暂停 youtube 视频,youtube api)
                  Youtube iframe api not triggering onYouTubeIframeAPIReady(Youtube iframe api 未触发 onYouTubeIframeAPIReady)
                  How can I stop a video with Javascript in Youtube?(如何在 Youtube 中停止使用 Javascript 的视频?)
                  Embed YouTube video - Refused to display in a frame because it set #39;X-Frame-Options#39; to #39;SAMEORIGIN#39;(嵌入 YouTube 视频 - 拒绝显示在框架中,因为它将“X-Frame-Options设置为“SAMEORIGIN)
                  How to call Greasemonkey#39;s GM_ functions from code that must run in the target page scope?(如何从必须在目标页面范围内运行的代码中调用 Greasemonkey 的 GM_ 函数?)
                  How do you mute an embedded Youtube player?(如何使嵌入式 Youtube 播放器静音?)

                  <legend id='pwF6J'><style id='pwF6J'><dir id='pwF6J'><q id='pwF6J'></q></dir></style></legend>
                1. <tfoot id='pwF6J'></tfoot>

                  <small id='pwF6J'></small><noframes id='pwF6J'>

                    <tbody id='pwF6J'></tbody>
                    <i id='pwF6J'><tr id='pwF6J'><dt id='pwF6J'><q id='pwF6J'><span id='pwF6J'><b id='pwF6J'><form id='pwF6J'><ins id='pwF6J'></ins><ul id='pwF6J'></ul><sub id='pwF6J'></sub></form><legend id='pwF6J'></legend><bdo id='pwF6J'><pre id='pwF6J'><center id='pwF6J'></center></pre></bdo></b><th id='pwF6J'></th></span></q></dt></tr></i><div id='pwF6J'><tfoot id='pwF6J'></tfoot><dl id='pwF6J'><fieldset id='pwF6J'></fieldset></dl></div>
                      • <bdo id='pwF6J'></bdo><ul id='pwF6J'></ul>