[英]How to display HTML from an array in ReactJS
I am new to ReactJS and I have a problem with my app. 我是ReactJS的新手,我的应用程序有问题。 I have an array:
我有一个数组:
players: [
{ number: 1, name: "Ben Blocker", position: "G" },
{ number: 2, name: "Dave Defender", position: "D" },
{ number: 3, name: "Sam Sweeper", position: "D" },
{ number: 4, name: "Matt Midfielder", position: "M" },
{ number: 5, name: "William Winger", position: "M" },
{ number: 6, name: "Fillipe Forward", position: "F" },
{ number: 7, name: "Bobby Ristov", position: "<h1>Test</h1>" }
],
And I would like to display the the H1
as HTML instead of text. 我想将
H1
显示为HTML而不是文本。 I have tried it like this <h1>Hi there!</h1>
我已经这样尝试过了
<h1>Hi there!</h1>
but that does not work either. 但这也不起作用。 Am I missing something here?
我在这里想念什么吗? Any help would be appriciated.
任何帮助将被申请。
它应该是一个元素,而不是字符串:
position: <h1>Test</h1>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.