如何在ReactJS中显示数组中的HTML

时间:2017-07-22 17:07:15

标签: javascript jquery html reactjs

我是ReactJS的新手,我的应用程序出了问题。我有一个数组:

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>" }
  ],

我想将H1显示为HTML而不是文本。我试过它&lt;h1&gt;Hi there!&lt;/h1&gt;,但这也不起作用。我在这里错过了什么吗?任何帮助都会得到满足。

1 个答案:

答案 0 :(得分:0)

它应该是一个元素,而不是字符串:

position: <h1>Test</h1>