reactjs - React Native 不能在文本中嵌套视图
问题描述
<View>
<Text>
{/* Adding notification if exists otherwise ignore */}
{post.hasNotification ? post.notifications: ''}
</Text>
</View>
如何将 View 组件包裹在 post.notifications 周围?当我这样做时,我得到一个错误,目前不支持带有文本的嵌套视图。我需要用一个 View 组件包装它,以便我可以设置它的样式。
解决方案
您不能在 Text 组件中使用 View 组件。尝试这个,
<View>
{post.hasNotification ? <View><Text>post.notifications</Text></View> : ' '}
</View>
推荐阅读
- c# - Unity中OverlapCircle与某些碰撞器之间的接触点
- string - Import String Values from a .csv file to MATLAB
- android - Android Studio BottomNavigationView 图标问题
- mercurial - 将 hg 条添加到 hgrc 配置文件
- forms - Play with Scala 中的复选框列表
- typescript - 如何定义一个 Typescript 函数,通过名称交换两个对象属性的值,并检查类型兼容性?
- python - 如何避免在 python 2.7 中使用 global?
- python - Numpy如何创建具有不同数据类型的一维数组
- swift - Swift macOS Process.run() 端口泄漏
- c# - 画布图像不能无缝滚动