如何在 React Native 中的 Text 组件内输出 <?

Mag*_*gne 5 jsx reactjs react-native

像这样: <Text> Math inequality: 3 < 2x </Text>

我如何转义这些字符,以便 JSX 不认为它是组件语法的一部分?

Ray*_*Ray 5

经过一些测试,我发现@stackdave 的答案不起作用。我不知道这是否适用于RN的其他版本,但react-native@0.51.0,我得到了以下错误:Cannot add a child that doesn't have a YogaNode to a parent without a measure function

您最好的选择(最安全/更好的语法突出显示明智)是这样做:

<Text>2 {'>'} 1</Text>
Run Code Online (Sandbox Code Playgroud)