我有一个非常具体的问题,所以:我在我的MySQL数据库中有一个中间文本。例如(带断线):
Lorem Ipsum is simply dummy text of the printing and typesetting industry.
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.我想现在使用get HTTP方法获取这篇文章,并在我的站点上显示,所有Lorem Ipsum都是粗体。
有什么可以得到的吗?我在Redux +Redux中使用ReactJS
或者可能是IN数据库,我可以在html中插入中间文本,但是如何在前端显示它呢?
发布于 2019-07-31 08:48:40
存储html并使用dangerouslySetInnerHTML呈现它。您可以更深入地阅读this post。
const text = '<strong>Lorem ipsum</strong> dolor sit';
const App = ({html}) => (
<div dangerouslySetInnerHTML={{ __html: html }} />
)
ReactDOM.render(<App html={text} />, document.getElementById('root'));<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<div id="root"></div>
https://stackoverflow.com/questions/57285788
复制相似问题