underscore.js定義模板遇到問題:Uncaught TypeError: Cannot read property 'replace' of undefined


代碼正確縮進位置如下,

extend "layout"

block 'content',->
   div ->'nihao'
   script id:"InvoiceItem",type:"text/template",style:"display: none",->
        div ->"{{price}}"
        div ->"{{quantity}}"
        div ->"{{amount}}"
   coffeescript ->
      $ ->
        invoiceItemModel = new InvoiceItemModel({price:5,quantity:3})
        (new PreviewInvoiceItemView({el:'body',model:invoiceItemModel})).render()

原因:引用了extend "layout"模板以后,要操作當前頁面的代碼,應該放在當前頁面代碼的內部,放在外部是訪問不到的,所以報錯:Uncaught TypeError: Cannot read property 'replace' of undefined


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM