我最近查看了 Google Firebase 的 quickstart-js/firestore/
存储库中的代码,当我在 index.html 中遇到以下
:html
时
63 <header id="site-header" class="mdc-toolbar mdc-toolbar--fixed">
64 <div id="title" class="mdc-toolbar__row mdc-layout-grid">
65 <section class="mdc-toolbar__section mdc-toolbar__section--align-start">
66 <span class="material-icons mdc-toolbar__icon--menu">restaurant</span>
67 <span class="mdc-toolbar__title">FriendlyEats</span>
68 </section>
69 </div>
70 <div id="section-header" data-fir-if="hasSectionHeader"></div>
71 </header>
72 </div>
此元素随后在 FriendlyEats.prototype.render()
函数的 firestore/scripts/FriendlyEats.View.js/
中引用:
407 'data-fir-if': function(tel) {
408 var field = tel.getAttribute('data-fir-if');
409 if (!that.getDeepItem(data, field)) {
410 tel.style.display = 'none';
411 }
412 },
我的问题是:data-fir-if
标签是什么意思,这是某种命名约定吗?如果是这样,命名约定是什么?我可以在哪里找到它的引用?
最佳答案
HTML attributes that begin with "data-"用于在该属性内存储数据,通常用于与该元素所表示的任何内容相关的内容。如果您仔细阅读代码,您会发现它与元素的显示方式有关。该代码明确指出,如果相关项目没有具有给定名称的字段,则不显示它。
关于javascript - `data-fir-if` HTML 标签引用什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55246795/