簡體   English   中英

無法調用未定義車把問題的方法'匹配'

[英]Cannot call method 'match' of undefined handlebar issue

我有我的模板與車把,工作時間最多,但有時給我這個錯誤不能調用undefined的方法'匹配'。 這是我的代碼

視圖

      <div id="template"></div>
            <script id="template-script" type="text/x-handlebars-template">  
                {{#measures_list}}      
                    <div class="col-lg-7  col-lg-offset-1">                     
                            <p class="indicator-title gray-bottom-border">{{name}}</br></p>
                            <div>
                                <p><span class="font30px">{{total}} </span> Total {{name}}<br><span class="green-text">{{increase}}%</span> from last <span class="metric_time"></span></p>
                            </div>
                            <div class="graph-header">
                                <h3>{{this_interval}} </h3><p>New {{name}}</p>
                                <p class="percentage-graph green-text">{{percentage}}%<p>
                            </div>                      
                        <div id={{graph_id}} class="graph"></div>

                    </div>
                {{/measures_list}} 
            </script>

JS

   var source=$("#template-script").html();
   var template=Handlebars.compile(source);
   $('#template').empty().append(template(template_data));
   console.log('source'+source+'template'+template)

我使用console.log來查看錯誤,因此很多次工作都很完美,但是在somme情況下來源未定義,頁面出現很多次,例如我單擊一個按鈕並在關閉頁面后再次單擊按鈕后出現做了很多次,經過多次或第一次給我錯誤之后: 不能調用undefined的方法'匹配'

請幫忙

var source=$("#template-script").html() || '';

我把所有腳本標簽都放在我的js中,就像一個變量而被調用而不是源代碼,我的修復是因為有時候無法找到是在那里,所以我改為我的js並且正在工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM