使用HTML属性数据 - preFIX与否? [英] Using html attribute data- prefix or not?
问题描述
AngularJS给出的选项,但不使用数据 - preFIX在其实施例或授权使用它。我应该包括数据 - preFIX为什么?
许多图书馆像淘汰赛,角等不使用数据 - preFIX。
块引用>使用数据 - * :
<跨度数据绑定=TEXT:myMessage>
使用数据 - * :指令可与X- pfixed $ P $或DATA-使它HTML验证标准(耻辱,他们不明白这是符合HTML而不是与验证)。
我应该包括数据 - preFIX?
块引用>是的,你应该写有效的HTML。如果您正在制作了属性,可以使用
数据 -
那些AngularJS gives the option of, but does not use the data- prefix in their examples or mandate the use of it. Should I include the data- prefix and why?
解决方案Many libraries like knockout, angular etc. do not use the data- prefix.
Knockout uses data-*: "
<span data-bind="text: myMessage">
"Angular uses data-*: "the directive can be prefixed with x-, or data- to make it HTML validator compliant" (shame they don't understand that it is for compliance with HTML and not with the validator).
Should i include the data- prefix ?
Yes, you should write valid HTML. If you are making up attributes, use
data-
ones.这篇关于使用HTML属性数据 - preFIX与否?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!