我成功地从WordPress网站获取了应用程序中的一些数据。像"„"这样的实体 反应原生 不想像引号和我遇到的更多问题一样。
有没有办法在 React Native 应用程序中制作 HTML 实体?
提前谢谢。
在渲染之前,您应该能够使用 html-entities 之类的东西来解码文本:
const entities = new Entities();
entities.decode('„') // "„" (double low quotation mark)
我遇到了同样的问题。 这是我解决它的方法:
首先安装 html 实体:
npm 安装 html-entities
在您的代码中:
import {decode} from 'html-entities';
console.log(decode(stringToBeDecoded));
以下是在"html-entities"自述文件中的示例(使用 require(((不适合您的情况下导入和使用实体的特定子包的方法。
import {Html5Entities} from 'html-entities';
const entities = new Html5Entities();
entities.decode(stringToBeDecoded);