gpt4 book ai didi

javascript - Backbone js 如何与 css 选择器交互?

转载 作者:行者123 更新时间:2023-11-28 21:11:37 24 4
gpt4 key购买 nike

我刚刚开始学习 Backbone js。几分钟后,我阅读了相当复杂的示例,但我不明白Backbone 模型如何与 DOM 选择器交互?

最佳答案

在 Backbone.js 中,模型根本不应该与 View 层交互。

另一方面, View 应该表示 View 中的模型更改,但 Backbone.js 没有对 DOM 操作、模板、CSS 等的任何内置支持:

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've already XSS-sanitized your interpolated data.

来自official documentation .

关于javascript - Backbone js 如何与 css 选择器交互?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8479438/

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