我想创建Text个组件,并将它们显示在一行中,比如html中的span个元素.如果我这样做:

<View>
  <Text> Start here, </Text> <Text> finish here </Text>
</View>

他们之间的线断了,看起来像:

从这里开始,

如何防止 break line 并将其显示在同一行上?

推荐答案

只要设定正确的flexDirection.默认值为column.

<View style={{flexDirection: 'row'}}>
 <Text> Start here, </Text> <Text> finish here </Text>
</View>

React-native相关问答推荐

React-Native:请纠正我对状态如何工作的误解 - 动态文本输入

React Native 应用程序没有在之前的工作代码中执行任何操作就无法运行

React Native - 何时调用componentWillUnmount?

React-native 重置数据库

react-native StyleSheet 属性和选项列表

withNavigation 只能用于导航器的视图层次 struct

ReactNative 0.43-rc.2 FlatList -- 试图获取超出范围索引 0 的框架

在 react-native 中调试原生 java 代码

React-Native Android - 找不到 com.android.tools:common

在本react-native中具有异步和等待的箭头函数

如果我有 AngularJS 基础知识,怎么学习Thinking in ReactJS呢?

FlatList vs map react-native

如何在 React Native 中使用 Jest

我可以使用 react native 开发 pwa

react-navigation模式高度

React-Native:更改 ImageBackground 的不透明度 colored颜色

React本机IOS,当TextInput获得焦点时,按钮按下不注册

如何在android studio中导入react native元素

Expo在使用Windows 10的android模拟器上运行

xcode 使用错误的 node.js 版本