首页 > 解决方案 > 在 HtmlView 中处理链接打开事件

问题描述

我有一个 html 代码,里面有一个链接。下面的代码是我的模板:

<HtmlView [html]="htmlString" ></HtmlView>

这是我的组件:

import { Component } from "@angular/core";

@Component({
    moduleId: module.id,
    templateUrl: "./creating-htmlview.component.html"
})

export class CreatingHtmlViewExampleComponent {
    public htmlString: string;

    constructor() {
        this.htmlString = '<a href="http://google.com/">google</a>';
    }
}

运行时如何处理aHtmlView 内部的元素?有没有办法检测用户何时运行链接?

标签: nativescript

解决方案


这还不支持,有一个开放的功能请求。你可以编写一个插件来实现像 ClickableSpan 或 Linkify 这样的原生 api。


推荐阅读