如何在本机反应中将子元素添加到特定元素

问题描述 投票:0回答:1

我想在react native中将元素添加到特定视图。谢谢您的回答。

react-native react-native-android react-native-ios
1个回答
0
投票

您可以通过这种方式添加元素

import React, { Component } from 'react';
import { Text, View } from 'react-native';

export default class HelloWorldApp extends Component {
  render() {
    return (
      <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
        <Text>Component 1</Text>
        <View style={{ flex: 1, justifyContent: "center", alignItems: "center" }}>
         <Text>Component 2</Text>
       </View>     
      </View>
    );
  }
}

这里是官方链接https://reactnative.dev/docs/tutorial

© www.soinside.com 2019 - 2024. All rights reserved.