var LayoutView = Backbone.View.extend({ initialize: function() { var self = this; $.get('resources/html/layout.html', function(data) { self.template = _.template(data); self.render(); }); }, render: function() { var self = this; $(self.el).html(self.template(self.model.toJSON())); } });
My rendering code :
$(document).ready(function() { var LayoutView= new LayoutView({ el:'#wrapper', model:{} }); });
定义view时如果是
var LayoutView= new LayoutView()这么定义的,就会报上面的错误,应该这么定义var layoutView= new LayoutView(),即改成小写的参考https://stackoverflow.com/questions/38025477/uncaught-typeerror-view-is-not-a-constructor
backbone中一个view调用另一个view的方法时报is not a constructor的问题
最新推荐文章于 2023-12-05 09:24:22 发布