什么是使用数据 - 而不是X-preFIX自定义属性的优势是什么? [英] What are the advantages of using data- rather than x- prefix for custom attributes?

查看:203
本文介绍了什么是使用数据 - 而不是X-preFIX自定义属性的优势是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

AngularJS文档 可选的指令可以prefixed以x-或DATA-使它HTML验证标准。

AngularJS documentation says Optionally the directive can be prefixed with x-, or data- to make it HTML validator compliant..

标记示例:


  1. 没有preFIX:<输入NG模型=名>

  2. 数据 - <输入数据-NG-模式=名>

  3. X - :<输入x-NG-模式=名>

  1. no prefix: <input ng-model="name">
  2. data- : <input data-ng-model="name">
  3. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆