<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'>

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

        时间:2023-09-06

        <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;
                  
                          }
                      }
                  

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

                  上一篇:Ember.js Application.inject 循环依赖 下一篇:如何将值从后端传递到 React 前端并在 CSS 中将该值用于前端?

                  相关文章

                  <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'>

                  <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>