0

我正在通过骨干开发应用程序,但现在出现同样的错误:

Uncaught TypeError: Object function (){ parent.apply(this, arguments); } has no method 'match'

当我添加调用新 Signupview 时,此错误开始出现:

define(["jQuery", "underscore", "Backbone", "Handlebars", "models/person", "views/signupview", "text!templates/loginview.html"], function ($, _, Backbone, Handlebars, Signupview, template) {
    var LoginView = Backbone.View.extend({
        template: Handlebars.compile(template),
        events: {
            "click .sign_up": "signUp_manual"
        },
        initialize: function () {
            this.render();
        },
        render: function () {
            var html = this.template();
            $('#pagina').html(this.$el.html(html)); //appendo ad el);
            return this;
        },
        signUp_manual: function () {
            console.log("signup");
            new Signupview();
        }
        //inserire funzione per log-in
    });
    return LoginView;
});

这里是注册视图:

define(["jQuery", "underscore", "Backbone", "Handlebars", "text!templates/signup.html"], function ($, _, Backbone, Handlebars, template) {
    var Signupview = Backbone.View.extend({
        template: Handlebars.compile(template),
        events: {},
        initialize: function () {
            this.render();
        },
        render: function () {
            var html = this.template();
            $('#pagina').html(this.$el.html(html)); //appendo ad el);
            return this;
        }
    });
    return Signupview;
});
4

1 回答 1

1

问题来自这条线,

define(["jQuery", "underscore", "Backbone", "Handlebars", "models/person", "views/signupview", "text!templates/loginview.html"], function ($, _, Backbone, Handlebars, PersonModel, Signupview, template) {
    //your code
});

您在回调函数中错过了 PersonModel 参数的地方

于 2014-11-06T06:56:01.697 回答