Underscore.js - 未捕获的ReferenceError:x未定义

时间:2012-10-01 22:29:40

标签: backbone.js requirejs underscore.js

我一直得到这个Uncaught ReferenceError:当我的脚本尝试渲染模板时,x未定义错误。此脚本使用backbone.js,require.js,underscore.js和jquery.js的组合。我花了一天时间尝试在线调试和搜索答案。有人知道发生了什么吗?

代码:

define([
    'jQuery',
    'Underscore',
    'Backbone',
    'text!templates/sharingFactory.html'
], function($, _, Backbone, SharingFactoryTemplate) {
    console.log('in SharingFactoryItemView');
    var SharingFactoryItemView = Backbone.View.extend({
        tagName: "span",
        initialize: function() {
            console.log('in initialize');
            this.template = _.template(SharingFactoryTemplate);
            console.log(this);
            this.render();
        },
        render: function () {
            console.log('in render');
            var data = this.model.toJSON();
            console.log(data);
            this.$el.html(this.template(data));
            return this;
        }
    });

    return SharingFactoryItemView; 
});

控制台日志:

in initialize SharingFactoryItemView.js:14
child
 SharingFactoryItemView.js:16
in render SharingFactoryItemView.js:20
Object
 SharingFactoryItemView.js:22
Uncaught ReferenceError: x is not defined

0 个答案:

没有答案
相关问题