什么是使用数据 - 而不是X-preFIX自定义属性的优势是什么? [英] What are the advantages of using data- rather than x- prefix for custom attributes?
问题描述
AngularJS文档说 可选的指令可以prefixed以x-或DATA-使它HTML验证标准。
。
AngularJS documentation says Optionally the directive can be prefixed with x-, or data- to make it HTML validator compliant.
.
标记示例:
- 没有preFIX:
<输入NG模型=名>
-
数据 -
:<输入数据-NG-模式=名>
-
X -
:<输入x-NG-模式=名>
- no prefix:
<input ng-model="name">
data-
:<input data-ng-model="name">
x-
:<input x-ng-model="name">
的 X -
preFIX快于数据类型 -
,但教程我见过使用,也没有preFIX或数据 -
,所以我的问题是:是否有我可能要使用的任何原因数据 -
,而不是 X - ?
The x-
prefix is faster to type than data-
, but the tutorials I have seen used either no prefix or data-
, so my question is: are there any reasons I might want to use data-
rather than x-
?
推荐答案
使用数据的优势 -
preFIX而非点¯x -
preFIX是数据 -
prefixes保证,因为他们喜欢保持可用作者,而一个 X -
preFIX有一天可能会被用于特定浏览器的目的,可能与你相互矛盾的。需要注意的是 X -
没有按照符合HTML5
The advantage of using a data-
prefix rather than an x-
prefix is that data-
prefixes are guaranteed to remain available to authors as they like, whereas an x-
prefix might one day be used for a browser-specific purpose, possibly conflicting with yours. Note that x-
are not conforming according to HTML5.
这篇关于什么是使用数据 - 而不是X-preFIX自定义属性的优势是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!