首页 > 解决方案 > 如何在 React 中包含 ASCII 码符号

问题描述

有什么方法可以在 React 中包含使用 ASCII 代码的图标。我已经在 HTML 中完成了这个,它工作得很好,但是当涉及到 React 时,它只会呈现整个字符串代码

<div class="page-btn">
    <span>1</span>
    <span>2</span>
    <span>3</span>
    <span>4</span>
    <span>&#8594</span> //in html this is a right arrow, in React this is just a plain code
</div>

标签: reactjs

解决方案


使用 javascript unicode 转义内联字符串。 右箭头是 Unicode 十六进制的 2192。(0x2192 == 十进制 8594)

<span>{"\u2192"}</span>


推荐阅读