我在 Ember.js 中有一个如下所示的 View :
MyApp.LoginView = Ember.View.extend({
templateName: 'login',
didInsertElement: function() {
$("body").addClass("light-bg");
$("footer").css("display", "none");
$("input[name=email]").focus();
},
willDestroyElement: function() {
$("body").removeClass("light-bg");
$("footer").css("display", "block");
}
});
我需要另一个完全相同的 View ,除了它被称为 ForgotPassword
,因此唯一的区别是 templateName
。
在 Ember.js 中有没有一种方法,我可以说 ForgotPassword
继承 Login
,然后将 templateName 设置为 forgotPassword
?
谢谢。
最佳答案
您可以简单地从刚刚创建的 View 扩展:
MyApp.YourOtherView = MyApp.LoginView.extend({
// whatever you do here will be applied to `YourOtherView` only.. so
templateName: 'other/template'
});
关于javascript - 如何在 Ember.js 中继承 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16471516/