【问题标题】:JSX expressions must have one parent element.ts(2657)JSX 表达式必须有一个父元素。ts(2657)
【发布时间】:2020-10-22 06:09:01
【问题描述】:

我正在使用 React Native,我是那里的新生,这里有什么问题:错误是存在的 我正在使用 React Native,我是那里的新生,这里有什么问题:错误在那里 我正在使用 React Native,我是那里的新生,这里有什么问题:错误在那里 我正在使用 React Native,我是那里的新生,这里有什么问题:错误在那里 我正在使用 React Native,我是那里的新生,这里有什么问题:错误在那里 我正在使用 React Native,我是那里的大一新生,这里有什么问题:错误在那里

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

export default function App() {
  return (
  


    <View style={styles.container}>
      <Text>Open up App.js to start working on your app!</Text>
      <StatusBar style="auto" />
    </View>

    <View >
<Text>ffff</Text>
      </View>
 
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'red',
  },
});

【问题讨论】:

  • 你遇到了什么问题?

标签: javascript java reactjs react-native


【解决方案1】:

您必须将内容包装在父部分或视图中,如下所示:

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

export default function App() {
  return (
    <>
      <StatusBar barStyle="dark-content"/>
      <View style={styles.container}>
        <Text>Open up App.js to start working on your app!</Text>
      </View>

      <View >
        <Text>ffff</Text>
      </View>
    </>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
    backgroundColor: 'red',
  },
});

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-09
    • 2020-07-30
    • 2022-01-05
    • 1970-01-01
    • 2023-02-13
    • 2020-04-24
    • 2021-11-09
    相关资源
    最近更新 更多