javascript HTML 文件中的“数据要求”“数据semver”是什么?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/21972470/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What are "data-require" "data-semver" in HTML files?
提问by J-16 SDiZ
I have seen tags like this in HTML. What are these attributes?
我在 HTML 中看到过这样的标签。这些属性是什么?
This is NOT a duplicate of the data-*
question.
这不是问题的重复data-*
。
Edit:I am looking for these two specific attributes, not data-*
in general, nor data-required, as Google suggests. If you search the web, you can find these attributes are used in many places. I guess this is some like of dependency management software?
编辑:我正在寻找这两个特定的属性,不是data-*
一般的,也不是 data-require d,正如谷歌建议的那样。如果你在网上搜索,你会发现这些属性在很多地方都有使用。我猜这有点像依赖管理软件?
<link data-require="bootstrap-css@*" data-semver="3.0.0" rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" />
<script data-require="[email protected]" src="https://ajax.googleapis.com/ajax/libs/angularjs/1.1.5/angular.js" data-semver="1.1.5"></script>
<script data-require="[email protected]" data-semver="0.5.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.6.0.js"></script>
回答by TimS
I was curious about this as well. These appear to be data- attributes that are created by plunkerwhen including external libraries in its editor. Since plunker is used heavily throughout the development community that is probably why you see it appearing a lot.
我也对这个很好奇。这些似乎是plunker在其编辑器中包含外部库时创建的数据属性。由于 plunker 在整个开发社区中被大量使用,这可能就是您看到它出现很多的原因。
By themselves they don't do anything special, unless a library or service decides to use them.
它们本身并没有做任何特别的事情,除非图书馆或服务决定使用它们。
The 'data-semver' attribute appears to be an implementation of Semantic Versioning
'data-semver' 属性似乎是语义版本控制的实现
To the best of my knowledge no libraries actually use them for any sort of dependency checking/loading.
据我所知,没有任何库实际上将它们用于任何类型的依赖项检查/加载。
回答by t.animal
The data-
attribute is new in HTML5and can be used to store arbitrary (text) data. The part after the '-' can be chosen by the author of the document. So you could have an attribute called myAge on the image of a person: <img src="imageOfMe.jpg" data-myAge="42" />
. It is mostly used to save data for javascript applications.
该data-
属性是HTML5中的新属性,可用于存储任意(文本)数据。'-' 后面的部分可以由文档的作者选择。所以,你可以有一个人的形象被称为myAge属性:<img src="imageOfMe.jpg" data-myAge="42" />
。它主要用于为 javascript 应用程序保存数据。