链接
一个用于显示可点击链接的 SwiftUI Link 组件。
iOS
tvOS
Bundled version:
~55.0.15
For the complete documentation index, see llms.txt. Use this file to discover all available pages.
Expo UI Link 与官方 SwiftUI Link API 相匹配。
🌐 Expo UI Link matches the official SwiftUI Link API.
安装
🌐 Installation
Terminal
- npx expo install @expo/uiIf you are installing this in an existing React Native app, make sure to install expo in your project.
用法
🌐 Usage
基本链接
🌐 Basic link
BasicLinkExample.tsx
import { Host, Link } from '@expo/ui/swift-ui'; export default function BasicLinkExample() { return ( <Host style={{ flex: 1 }}> <Link label="Visit Expo" destination="https://expo.dev" /> </Host> ); }
自定义标签内容
🌐 Custom label content
你可以将自定义组件作为 children 传递,以实现更复杂的链接标签内容。
🌐 You can pass custom components as children for more complex link label content.
CustomContentExample.tsx
import { Host, Link, VStack, Image, Text } from '@expo/ui/swift-ui'; export default function CustomContentExample() { return ( <Host matchContents> <Link destination="https://expo.dev"> <VStack spacing={4}> <Image systemName="link" /> <Text>Expo</Text> </VStack> </Link> </Host> ); }
应用接口
🌐 API
import { Link } from '@expo/ui/swift-ui';
Component
Type: React.Element<LinkProps>
Displays a native link component.
Example
import { Link } from '@expo/ui/swift-ui'; import { foregroundStyle, font } from '@expo/ui/swift-ui/modifiers'; <Link label="Open" destination="https://expo.dev" modifiers={[ foregroundStyle('red'), font({ size: 24, weight: 'bold' }) ]} />