2016-10-09 5 views
1

핸들 막대 템플릿에서 BackboneJS로 레일에서 작업하고 있습니다.잡히지 않은 유형 오류 : this.template이 함수가 아닙니다. Backbonejs

여기 이상한 오류를 얻고있다 .. 을이되어 내 헤더보기

class App.Views.Header extends Backbone.View 

    className: "navbar-inner" 
    template: HandlebarsTemplates['app/templates/header'] 

    render: -> 
    @$el.html(@template()) 
    @ 

기본 응용 프로그램 파일입니다이

#= require_self 
#= require_tree ./templates 
#= require_tree ./views 
#= require_tree ./routers 

window.App = 
    Routers: {} 
    Views: {} 
    Collections: {} 
    Models: {} 
    initialize: -> 
    new App.Routers.MainRouter() 
    Backbone.history.start() 

내 주요 라우터 파일이

class App.Routers.MainRouter extends Backbone.Router 

    routes: 
    "": "index" 

    initialize: -> 
    @headerView = new App.Views.Header() 

    index: -> 
    $("#header").html(@headerView.render().el) 
한다

내가 localhost:3000에 도착했을 때 ..이 오류가 발생했습니다. Uncaught TypeError: this.template is not a function ..한다는 점에서

암 완전히 붙어 어떤 도움이 이해할 수있을 것이다 감사

답변

0

그것은 HandlebarsTemplates['app/templates/header']에 핸들 템플릿처럼 들린다 존재하지 않습니다는 컴파일되지 않았거나 컴파일하는 동안 오류가되었을 수도 있습니다 그것. 그 값이 null이거나 정의되지 않은 경우 오류가 발생합니다.

브라우저의 자바 스크립트 디버거에서 render을 호출하여 중단 점을 설정 한 다음 디버거를 사용하여 this.template의 값을 확인하고 진행 상황을 확인할 수 있습니다.

+0

'template : HandlebarsTemplates [ 'header']'this works worked – ijunaidfarooq

2

template: HandlebarsTemplates['header']

템플릿 경로는 템플릿 자체가되어야한다.

미리 컴파일 된 버전 또는 자산으로 인해 버전이 변경 될 수도 있습니다.

관련 문제