gpt4 book ai didi

javascript - `data-fir-if` HTML 标签引用什么?

转载 作者:行者123 更新时间:2023-11-30 14:06:43 25 4
gpt4 key购买 nike

我最近查看了 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com