Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
370 views
in Technique[技术] by (71.8m points)

javascript - React JSX, how to render text with a single quote? Example <p>I've</p>

In React JSX how can I have the following text include a single quote? Or other punctuation that might need escaping?

 return (<p>I've seen the movie.</p>)
question from:https://stackoverflow.com/questions/32979512/react-jsx-how-to-render-text-with-a-single-quote-example-pive-p

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Render as a JS string literal (with double-quotes):

return (<p>{"I've seen the movie."}</p>)

... or use the HTML entity for an apostrophe, &apos;:

return (<p>I&apos;ve seen the movie.</p>)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...