簡體   English   中英

JSRender如何在塊外訪問變量

[英]JSRender how to access variable outside the block

我正在使用jsrender顯示json對象的詳細信息。 我想知道如何訪問列表中的外部變量。 謝謝。

   <script id="itemTemplate" type="text/x-jQuery-tmpl">

            {{=outsideVariable}} //STRING
            <div id="receipt_list_container">
                {{#each receiptSummary.receipts}}  //LIST
                    {{=formattedMonth}}
                                //HOW CAN I ACCESS THE OUTSIDE THE VARIABLE
                {{/each}}
            </div>

    </script>

據我了解,這是您的示例: 示例方案:訪問父數據。

var model = {
    specialMessage: function(...) { ... },
    theater: "Rialto",
    movies: [ ... ]
}

{{for movies}}
    <tr>
        <td>'{{>title}}': showing at the '{{>#parent.parent.data.theater}}'</td>

暫無
暫無

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

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