我是backbonejs 世界的初学者,我从Addy Osmani 的Backbonejs Application 那里买了一本书。我正在读这本书,我尝试用backbonejs 构建一个应用程序。在书中的某个地方,他写了一段关于backbonejs 扩展的部分,并公开了如何使用marionettejs。我访问了 Githubbonejs 扩展站点,他们有很多扩展,包括 marionettejs。现在我对使用backbonejs感到困惑,我是否也应该使用像Marionettejs这样的扩展?我知道扩展可以为 web 开发带来很多好处,当我要使用backbonejs 时,我也应该使用 marionettejs 吗?什么时候使用扩展有用,什么时候不使用?
1 回答
I find Marionette to be a useful addition to Backbone, because it reduces the amount of repetitive code you need to write (unbinding event listeners when views close, rendering one view for each item in a collection and attaching it to the DOM, etc.).
There's a nice (short) comparison of Marionette and plain Backbone here: http://addyosmani.github.io/backbone-fundamentals/#boilerplate-rendering-code
Ultimately, the best tool for you will depend on what you want to achieve and what your preferences are.
Full disclosure: I may not be entirely objective, since I'm writing a book on Marionette. But I'm sure other members will provide you with their own opinions.