gpt4 book ai didi

javascript - 'production' 代码中不推荐使用 jQuery .css

转载 作者:太空狗 更新时间:2023-10-29 15:05:21 26 4
gpt4 key购买 nike

jQuery documentation发表评论,'不建议在生产就绪代码中使用 .css() 作为 setter,但在传入对象以设置 CSS 时,CSS 属性将采用驼峰式命名,而不是使用连字符。'

a) 为什么不建议在生产就绪代码中使用它?

b) “但是​​当传入一个对象来设置 CSS 时,CSS 属性将采用驼峰式命名而不是使用连字符。”

所以 jQuery 会在内部将“font-family”修改为“fontFamily”,或者这只是这里的一个建议?

有没有经验丰富的程序员可以进一步澄清这一点?

最佳答案

您对点 a 的回答可以在您链接到的同一页面上找到:

Using CSS Classes for Styling

As a getter, the .css() method is valuable. However, it should generally be avoided as a setter in production-ready code, because it's generally best to keep presentational information out of JavaScript code. Instead, write CSS rules for classes that describe the various visual states, and then change the class on the element.

关于javascript - 'production' 代码中不推荐使用 jQuery .css,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19647532/

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