我可以将(单击)事件的函数添加到我使用替换方法添加的跨度标签中吗?
https://i.sstatic.net/b5dow.png 我有这样的句子,如您所见,如果我要寻找的单词在该句子中,我将其放在跨度标签中。
.replace(query.toLocaleLowerCase(), `<span>${query}</span>`,).toLocaleLowerCase()
(查询是我的搜索字) 我想在这样的跨度标签中拿起这个词,
`<span (click)="myFunction()">${query}</span>`
有办法做到这一点吗?
https://i.sstatic.net/B5doW.png
I have sentences like this, and as you can see, if the word I'm looking for is in that sentence, I put it in span tags.
.replace(query.toLocaleLowerCase(), `<span>${query}</span>`,).toLocaleLowerCase()
(query is my search word)
and I want to make the word taken in these span tags like this
`<span (click)="myFunction()">${query}</span>`
Is there a way to do this ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我得到了这样的解决方案,这不是很正确,但是最简单的
ts side
}
html侧;
I got the solution like this, it's not quite right, but the simplest
TS Side
}
HTML side;
你尝试过吗?
Have you tried