简体   繁体   English

如何在字符串中呈现变量<text> React Native 中的 JSX 标签</text>

[英]How to render variable in string in <Text> JSX tag in React Native

How to enable template string in React Native?如何在 React Native 中启用模板字符串? My code doesn't work:我的代码不起作用:

<Text>{`My name is ${name}`}</Text>

There is no need of adding template strings inside a <Text> component for adding strings in react-native .无需在<Text>组件中添加模板字符串即可在react-native中添加字符串。 You can just use simple text and for variables, you can wrap it with curly braces.你可以只使用简单的文本,对于变量,你可以用花括号括起来。

<Text>My name is {name}</Text>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM