React Native View2025 年 3 月 17 日 | 阅读 1 分钟 View 是 React Native 中构建用户界面的基本组件。 它是一个容器,支持使用 flexbox 进行布局、样式、触摸处理和辅助功能控制。 它直接映射到本机视图,类似于 React Native 应用程序运行的任何平台。 无论使用 UIView, <div>, android.view, 等,它都会显示组件。 View 组件可以嵌套,包含其内部的其他视图。 它可以包含 0 到多个任何类型的子组件。 注意:与 StyleSheet 结合使用的 View 组件使其更清晰且性能更好,但是,它也支持内联样式View 的 PropsonStartShouldSetResponder | accessibilityLabel | accessibilityHint | hitSlop | nativeID | onAccessibilityTap | onLayout | onMagicTap | onMoveShouldSetResponder | onMoveShouldSetResponderCapture | onResponderGrant | onResponderMove | onResponderReject | onResponderRelease | onResponderTerminate | onResponderTerminationRequest | accessible | onStartShouldSetResponderCapture | pointerEvents | removeClippedSubviews | style | testID | accessibilityComponentType | accessibilityLiveRegion | collapsable | importantForAccessibility | needsOffscreenAlphaCompositing | renderToHardwareTextureAndroid | accessibilityRole | accessibilityStates | accessibilityTraits | accessibilityViewIsModal | accessibilityElementsHidden | accessibilityIgnoresInvertColors | shouldRasterizeIOS |
React Native View 示例在此示例中,我们创建一个 View 组件,其中包含两个彩色框和一个具有高度和宽度的文本组件,它们在一行中排列。 App.js 输出 
|