简体   繁体   中英

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. I tried enclosing the script tag in span but its still doesn't work, same is happening with <input> and <canvas>

Replace the Less than sign ( < ) with &lt; and similarly replace the Greater than sign ( > ) with &gt; .

So your code will become:

 &lt;script src='script.js'&gt;&lt;/script&gt;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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