【问题标题】:Adding router links to a paragraph in Angular NativeScript将路由器链接添加到 Angular NativeScript 中的段落
【发布时间】:2019-11-16 03:13:21
【问题描述】:

尝试格式化包含多个文本链接的段落或句子。这些链接将是路由器链接,而不是外部网络链接。

看起来您可以使用 FormattedString 和 Span 格式化文本,但似乎您无法将 nsRouterLink 添加到 Span。

<Label class="terms">
    <FormattedString>
        <Span text="By creating an account, you agree to the our "></Span>
        <Span
            text="Terms of Use"
            class="link"
            [nsRouterLink]="['/policies/terms-of-use']"
            pageTransition="slideLeft"
        ></Span>
        <Span text=" and "></Span>
        <Span
            text="Privacy Policy"
            class="link"
            [nsRouterLink]="['/policies/privacy-policy']"
            pageTransition="slideLeft"
        ></Span>
        <Span text="."></Span>
    </FormattedString>
</Label>

如果我可以让整个内容都可点击,我可以将所有内容都包裹在一个按钮中,但正如您在示例中看到的那样,那里有两个单独的链接。

【问题讨论】:

    标签: angular nativescript angular2-nativescript


    【解决方案1】:

    不幸的是,尚不支持 Span 上的点击事件。 open feature request 已经有一段时间了。

    虽然你可以在 Github 中找到一个 example 用一些本机代码识别水龙头。您可能必须实现相同并从侦听器调用导航方法。

    【讨论】:

      猜你喜欢
      • 2017-03-06
      • 1970-01-01
      • 1970-01-01
      • 2020-08-09
      • 1970-01-01
      • 2021-01-27
      • 2015-11-28
      • 2019-05-03
      • 1970-01-01
      相关资源
      最近更新 更多