我有一个span标签,里面的html是这样的。
在我的html中。
<span [innerHTML]="description"></span>
和我的TS中。
description = "some random text https://stackoverflow.com/ Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s"
它显示了链接,但当我点击该链接时,它是在同一个标签页中打开的,但我希望它是在一个新的标签页中打开的。
有什么方法可以做到这一点吗?
在这种情况下,如果你使用innerHtml属性绑定,你可以在标签中放置一个 html链接 在您的描述文字中加入 target="_blank" 在新标签页中打开链接。
description =
'some random text <a href="https://stackoverflow.com" target="_blank">https://stackoverflow.com/</a> Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry\'s standard dummy text ever since the 1500s';