【问题标题】:Is there any equivalent to the HTML anchor tag on Nativescript?是否有与 Nativescript 上的 HTML 锚标记等效的内容?
【发布时间】:2017-02-25 02:30:35
【问题描述】:

我正在尝试显示带有链接的简单图像或文本,例如 HTML <a> 锚标记

  <ListView [items]="items | async" (itemTap)="onItemTap($event)">
    <template let-item="item">
      <StackLayout>
        <Image [src]="item.imageUrl" ></Image> 
 <!--<Image [src]="item.imageUrl" href="http://google.com"></Image>-->
      </StackLayout>
    </template>
  </ListView>

似乎唯一的选择是使用 onItemTap 并获取项目 url 并手动设置要在单独的 webview 上显示的 url 内容。是否有任何标签会自动在手机上打开单独的浏览器页面并显示项目的 URL 内容?

【问题讨论】:

  • 认为您必须创建功能,然后您可以使用所需的 URL 打开浏览器。

标签: javascript html angular nativescript angular2-nativescript


【解决方案1】:

对于您的情况,您可以使用openUrl() 并在某些组件上点击事件以打开所需的页面。例如:

export function onTap(args:EventData){        
    openUrl("https://www.google.com");
}

您还可以查看示例项目here

【讨论】:

  • +1,但我必须首先需要 utils 模块 var utilsModule = require("tns-core-modules/utils/utils"); 并使用 utilsModule.openUrl("https://www.google.com")
猜你喜欢
  • 2018-11-09
  • 2018-04-09
  • 2021-11-09
  • 1970-01-01
  • 2014-05-28
  • 1970-01-01
  • 2013-09-13
  • 2011-09-21
  • 1970-01-01
相关资源
最近更新 更多