使用HTML属性数据 - preFIX与否? [英] Using html attribute data- prefix or not?

查看:234
本文介绍了使用HTML属性数据 - preFIX与否?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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屋!

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