我正在使用 Vue.js 生成 div,我想使用 JSON 文件中的数据来执行此操作。
它不一定必须来自 JSON,但这会更好,我只需要为下面 html 中的每个 div 实例创建一个唯一的 id。
为每个 div 创建唯一 ID 的最佳方法是什么?
HTML
<ul>
<li v-for="(member, index) in cyclists" :key="index" class="col-md-4 inview fromBottomIn" data-in="fromBottomIn" data-out="fromBottomOut">
<div class="cycling__card">
<div class="cycling__rider-container">
<span class="cyclist__name">{{member.name}}</span>
</div>
<!-- Need to add id's to the div below -->
<div id={{member.name}}>
</div>
</div>
</li>
</ul>
Run Code Online (Sandbox Code Playgroud)
JSON
"cyclists": [
{
"name": "Jason",
"position": "CEO",
},
{
"name": "Mike",
"position": "Digital Strategist",
},
{
"name": "Tom",
"position": "Vice President, Product Management",
},
{ …Run Code Online (Sandbox Code Playgroud) 如果您检查自定义复选框并单击“活动”元素状态,您会注意到复选框中出现蓝色背景。这也可以通过在自定义复选框内按住鼠标而不释放来重现。
我正在尝试使用:active选择器删除蓝色背景/阴影,但它没有应用样式。
这是我的代码:
.custom-control-input:active {
background-color: none !important;
box-shadow: none !important
}
Run Code Online (Sandbox Code Playgroud) 此问题要求您创建一个算法来确定字符串是否具有唯一字符.我正在寻找解决方案,这似乎是我能找到的最简单的解决方案,但是这段代码仍有一些部分我无法解决.
boolean [] chars = new boolean [26]; 编码器到底在做什么?26个字符代表字母表中的26个字母.我问,因为当我摆弄代码并将值更改为12,15,20等时,程序仍然提供正确的输出.
if(chars [(int)c - 'A'])从int c中减去'A'的目的是什么?我已经看到这种方法在多个解决方案中减去"A"或"a"来解决这个问题,但我不明白它的用途是什么.
public class PracticeProblems {
public static void questionOne(String input) {
boolean[] chars = new boolean[26];
String upper = input.toUpperCase();
for(int i = 0, n = upper.length(); i < n; i++){
char c = upper.charAt(i);
if ('A' <= c && c <= 'Z'){
if(chars[(int)c - 'A']){
System.out.println("not unique");
return;
}
chars[(int)c - 'A'] = true;
}
}
System.out.println("unique");
}
public static void main(String[] args) {
questionOne("bil"); …Run Code Online (Sandbox Code Playgroud)