main
分支
main (6.23.1)dev
版本
6.23.1v4/5.xv3.x
Link (RN)

<Link> (React Native)

這是 <Link> 的 React Native 版本。如需了解網路版本,請按這裡

類型宣告
declare function Link(props: LinkProps): React.ReactElement;

interface LinkProps extends TouchableHighlightProps {
  children?: React.ReactNode;
  onPress?(event: GestureResponderEvent): void;
  replace?: boolean;
  state?: any;
  to: To;
}

<Link> 是一個元件,讓使用者能夠透過點擊來導覽到其他檢視,類似網路應用程式中 <a> 元件的功能。在 react-router-native 中,<Link> 會渲染一個 TouchableHighlight。若要覆寫預設的樣式和行為,請參閱 TouchableHighlight 的屬性參考

import * as React from "react";
import { View, Text } from "react-native";
import { Link } from "react-router-native";

function Home() {
  return (
    <View>
      <Text>Welcome!</Text>
      <Link to="/profile">
        <Text>Visit your profile</Text>
      </Link>
    </View>
  );
}