Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/83.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在react.js中像纯文本一样显示javascript/html代码_Javascript_Html_Reactjs_React Native - Fatal编程技术网

在react.js中像纯文本一样显示javascript/html代码

在react.js中像纯文本一样显示javascript/html代码,javascript,html,reactjs,react-native,Javascript,Html,Reactjs,React Native,如何在react.js render中显示javascript/html代码 我试过这样做 var thisIsMyCopy = '<p>copy copy copy <strong>strong copy</strong </p>'; return ( <div> <div dangerouslySetInnerHTML={{__html: thisIsMyCopy}}> </di

如何在react.js render中显示javascript/html代码

我试过这样做

var thisIsMyCopy = '<p>copy copy copy <strong>strong copy</strong </p>';

return (
    <div>
        <div dangerouslySetInnerHTML={{__html: thisIsMyCopy}}>
        </div>
    </div>
)

var thisIsMyCopy='copy-copystrong-copy它已经在一个字符串版本中,只需要在花括号中包含变量
DangerouslySetinerHTML
用于将html字符串转换为实际html

var thisIsMyCopy = '<p>copy copy copy <strong>strong copy</strong </p>';

return (
  <div>
    {thisIsMyCopy}
  </div>
)

var thisIsMyCopy='copy-copystrong-copy它已经在一个字符串版本中,只需要在花括号中包含变量
DangerouslySetinerHTML
用于将html字符串转换为实际html

var thisIsMyCopy = '<p>copy copy copy <strong>strong copy</strong </p>';

return (
  <div>
    {thisIsMyCopy}
  </div>
)

var thisIsMyCopy='copy copystrong copy如果要在html中显示“代码”,可以使用

<code>something</code>

标记,它将在屏幕上显示您的代码。

如果您想在html中显示“代码”,可以使用

<code>something</code>

标记,它将在屏幕上显示您的代码。

您永远不应该使用
危险的HTML
。我建议您立即停止。您永远不应该使用
危险的LysetinerHTML
。我建议你马上停下来。你能更具体地说明你的意思吗?比如字符串化的javascript函数?正如您在代码编辑器中看到的那样?您能更具体地说明您的意思吗?比如字符串化的javascript函数?正如您在代码编辑器中看到的那样(但仅限于HTML5;)它在react中不起作用,但只在HTML5中起作用;)这样的反应对我来说不起作用。