2 回答

TA貢獻(xiàn)1993條經(jīng)驗(yàn) 獲得超6個(gè)贊
我不確定如何標(biāo)記為重復(fù),
基本上你想將字符串呈現(xiàn)為 HTML,這是一種危險(xiǎn)的做法,所以要小心。
const x = {
? ? ? ? titleName: "Indorction",
? ? ? ? heading: 'Welcome to JavaScript',
? ? ? ? iconName: faDotCircle,
? ? ? ? description: [
? ? ? ? ? ? `
? ? ? ? ? ? Do we even need to introduce <p>HTML element</p>? It’s one of the most popular programming?
? ? ? ? ? ? languages on the planet!
? ? ? ? ? ? Ever visited a website that made you think…"Hey, this website is really cool and
? ? ? ? ? ? `
? ? ? ? ],
? ? },
在你的渲染函數(shù)中:
<div dangerouslySetInnerHTML={{ __html: x.description }}></div>

TA貢獻(xiàn)2080條經(jīng)驗(yàn) 獲得超4個(gè)贊
JavaScript_Lessons_Objects.js
{
titleName: "Indorction",
heading: 'Welcome to JavaScript',
iconName: faDotCircle,
description: [
`
Do we even need to introduce <b class="hal">JavaScript</b>? It’s one of the most
popular programming languages on the planet!.
`
],
},
課程.jsx
{ReactHtmlParser(this.props.lesson[this.state.indexDescription]["description"])}
添加回答
舉報(bào)