• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Hyperlink
2
3超链接组件,组件宽高范围内点击实现跳转。
4
5>  **说明:**
6>
7>  - 该组件从API Version 7开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。
8>  - 该组件仅支持与系统浏览器配合使用。
9
10## 需要权限
11
12使用网络时,需要申请权限ohos.permission.INTERNET。具体申请方式请参考[权限申请声明](../../security/accesstoken-guidelines.md)。
13
14## 子组件
15
16可以包含子组件。
17
18
19## 接口
20
21Hyperlink(address: string | Resource, content?: string | Resource)
22
23从API version 9开始,该接口支持在ArkTS卡片中使用。
24
25**参数:**
26
27| 参数名 | 参数类型 | 必填 | 参数描述 |
28| -------- | -------- | -------- | -------- |
29| address | string \| [Resource](ts-types.md#resource) | 是 | Hyperlink组件跳转的网页。 |
30| content | string&nbsp;\|&nbsp;[Resource](ts-types.md#resource) | 否 | Hyperlink组件中超链接显示文本。<br/>**说明:** <br/>组件内有子组件时,不显示超链接文本。 |
31
32## 属性
33
34仅支持以下属性:
35
36| 名称 | 参数类型 | 描述 |
37| -------- | -------- | -------- |
38| color | [ResourceColor](ts-types.md#resourcecolor) | 设置超链接文本的颜色。 |
39
40## 示例
41
42```ts
43@Entry
44@Component
45struct HyperlinkExample {
46  build() {
47    Column() {
48      Column() {
49        Hyperlink('https://example.com/') {
50          Image($r('app.media.bg'))
51            .width(200)
52            .height(100)
53        }
54      }
55
56      Column() {
57        Hyperlink('https://example.com/', 'Go to the developer website') {
58        }
59        .color(Color.Blue)
60      }
61    }.width('100%').height('100%').justifyContent(FlexAlign.Center)
62  }
63}
64```
65
66![hyperlink](figures/hyperlink.PNG)
67