gpt4 book ai didi

backbone.js - backboneJS 使用哪种模板方法?

转载 作者:行者123 更新时间:2023-12-02 18:09:27 24 4
gpt4 key购买 nike

我使用过 Angular,它使用基于 DOM 的模板,也在 Ember 中使用基于字符串的模板。但我从来没有在 Backbone 上工作过。谁能告诉我它使用哪种模板方法?

最佳答案

Backbone 不会强制您使用任何特定的模板引擎,您可以使用您想要的渲染模板。

Render the UI as you see fit. Backbone is agnostic as to whether you use Underscore templates, Mustache.js, direct DOM manipulation, server-side rendered snippets of HTML, or jQuery UI in your render function. Sometimes you'll create a view for each model ... sometimes you'll have a view that renders thousands of models at once, in a tight loop. Both can be appropriate in the same app, depending on the quantity of data involved, and the complexity of the UI.

(来源:http://backbonejs.org/#FAQ-tim-toady)

Backbone is agnostic with respect to your preferred method of HTML templating. Your render function could even munge together an HTML string, or use document.createElement to generate a DOM tree. However, we suggest choosing a nice JavaScript templating library. Mustache.js, Haml-js, and Eco are all fine alternatives. Because Underscore.js is already on the page, _.template is available, and is an excellent choice if you prefer simple interpolated-JavaScript style templates.

(来源:http://backbonejs.org/#View-render)

(rtfm!)

关于backbone.js - backboneJS 使用哪种模板方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19831171/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com