我该如何在Ionic中创建获取迭代段落的功能?

问题描述

我有这个重复的段落。

ts

notifications[];
paintIt() {
    this.notifications.forEach((value,index) => {
     if (value.isSelected=== true) {
       var text = value.versetext;
          console.log(text);
          let color = "yellow";
          let inputText = document.getElementById("inputText");
          let innerHTML = inputText.innerHTML;
          let su = innerHTML.indexOf(text);
            if (su >= 0 ) {
              innerHTML = innerHTML.substring(0,su) + "<span style='background-color: " + color + ";'>" + innerHTML.substring(su,su + text.length) + "</span>" + innerHTML.substring(su +(text).length);
              inputText.innerHTML = innerHTML;
            }
            this.unselectAll();
       }
    });
    
  }

html

<div id="inputText" *ngFor="let versedata of books?.chapters;let i=index;let notification of notifications; " tappable text-wrap (click)=selectItem(i,notification) (press)=selectItem(i,notification) [ngStyle]="{'background-color': notification.isSelected ? '#ffffff':'#e8ebf1' }"
                    ngDefaultControl>

                    <ion-label>
                        <p >
                            {{versedata.versetext}}</p>
                    </ion-label>
                    
                </div>

该函数可以到达第一个迭代div,但不能到达第二个,而不是第三个div 是因为该函数认为由于它已经使用id =“ input text”访问了div,所以突出显示了该文本? 在下面的迭代div中,如何找到其他段落?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...