2017-04-06 4 views
0

와 핸들 바를 사용하는 방법은 다음과 같은 오류가 발생은 RequireJS

requirejs.config({ 
    baseUrl: "resources", 
    paths: { 
     'app':'lib', 
     'jquery': 'lib/jquery-1.9.1', 
     'bootstrap': 'lib/bootstrap', 
     'html5shiv': 'lib/html5shiv', 
     'spin': 'lib/spin', 
     'respond': 'lib/respond', 
     'underscore': 'lib/underscore', 
     'backbone': 'lib/backbone', 
     'handlebars': 'lib/handlebars-v3.0.3', 
     'template': 'app/templates' 
    }, 
    shim: { 
     html5shiv: { 
      deps: ['jquery'] 
     }, 
     respond: { 
      deps: ['jquery'] 
     }, 
     bootstrap: { 
      deps: ['jquery'] 
     }, 
     jquery: { 
      exports: '$' 
     }, 
     underscore: { 
      exports: '_' 
     }, 
     backbone: { 
      deps: ['jquery', 'underscore'], 
      exports: 'Backbone' 
     }, 
     handlebars: { 
      exports: "Handlebars" 
     } 
    } 
}); 

require([ 
    'jquery', 
    'underscore', 
    'backbone', 
    'handlebars', 
    'app/Router' 
], function($, 
      _, 
      Backbone, 
      Handlebars, 
      Router) { 
    var router = new Router(); 
    Backbone.history.start(); 
}); 

보기 :

define([ 
    'backbone', 
    'handlebars', 
    'text!templates/mytemplate.html' 
], function(Backbone, Handlebars, Template){ 

    MyView = Backbone.View.extend({ 
     tagName: 'li', 
     template: Handlebars.compile(Template), 

     render: function() { 
      this.$el.html(this.template(this.model.toJSON())); 
      return this; 
     } 
    }); 

    return MyView; 
}); 

답변

0

shim 지원하지 않는 라이브러리입니다 AMD. 사용중인 핸들의 버전은 아마 AMD를 지원하고 Handlebars라는 이름의 전역 변수를 정의하지 않습니다. 따라서 오류가 발생합니다. 심에서 handlebars 설정을 제거하십시오.