[英]How write html code in string to create a code snippet?
<Modal show={props.show} onHide={() => props.close()} size="lg" centered aria-labelledby="contained-modal-title-vcenter" >
<Modal.Header closeButton>
<Modal.Title>Modal heading</Modal.Title>
</Modal.Header>
<Modal.Body>
some random text................
You include the script with the following code:
<script src='script.js'></script>
</Modal.Body>
<Modal.Footer>
<Button variant="secondary" onClick={() => props.close()}>
Close
</Button>
<Button variant="primary">
Download
</Button>
</Modal.Footer>
</Modal>
In the above code I want the script tag line in Modal.Body
to be displayed as text but instead the code is being executed.在上面的代码中,我希望Modal.Body
中的脚本标记行显示为文本,而是执行代码。 I tried enclosing the script tag in span
but its still doesn't work, same is happening with <input>
and <canvas>
我尝试将脚本标签包含在span
中,但它仍然无法正常工作, <input>
和<canvas>
也是如此
Replace the Less than sign ( <
) with <
将小于号( <
) 替换为<
and similarly replace the Greater than sign ( >
) with >
并类似地将大于号( >
) 替换为>
. .
So your code will become:所以你的代码将变成:
<script src='script.js'></script>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.