requirejs中的句柄加载不成功 [英] handlebars in requirejs load not successfully

查看:118
本文介绍了requirejs中的句柄加载不成功的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 路径:{
jquery:'libs / jquery / jquery-min',
下划线:'libs / underscore / underscore-min',
骨干:'libs / backbone / backbone-optamd3-min',
handlebars:'libs / handlebars / handlebars',
text:'libs / require / text'
}

define([
'jquery',
'underscore',
'backbone',
'collections / todos',
'views / todos ',
'text!templates / stats.html',
'common',
'handlebars'
],function($,_,Backbone,Todos,TodoView,statsTemplate ,常见的,把手){
//把手是空的
console.log(把手是,把手);





$ b除了把手,其他人可以成功加载。为什么以及如何使加载成功。谢谢

解决方案

首先,我可以看到你是新的,但请尝试添加更多的细节到你的问题,以帮助其他人帮助你。



从源头上看,我不认为Handlebars与AMD兼容,因此您需要自行填充。像这样:

  requirejs.config({
shim:{
'handlebars':{
出口:'把手'
}
}
});


paths: {
          jquery: 'libs/jquery/jquery-min',
          underscore: 'libs/underscore/underscore-min',
          backbone: 'libs/backbone/backbone-optamd3-min',
          handlebars: 'libs/handlebars/handlebars',
          text: 'libs/require/text'
      }

   define([
      'jquery',
       'underscore',
       'backbone',
       'collections/todos',
       'views/todos',
       'text!templates/stats.html',
       'common',
       'handlebars'
  ], function ($, _, Backbone, Todos, TodoView, statsTemplate, Common, handlebars) {
   //handlebars is null
   console.log("handlebars is",handlebars);

})

Except handlebars,others can load successfully.Why and how to make handlbars load successfully.thanks

解决方案

Firstly, I can see that you're new but please try to add more detail to your question to help others help you.

From glancing at the source I don't think Handlebars is compatible with AMD, therefore you will need to shim it yourself. Something like this:

requirejs.config({
    shim: {
        'handlebars': {
            exports: 'Handlebars'
        }
    }
});

这篇关于requirejs中的句柄加载不成功的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆