反应本机 HTML 个实体
React native HTML entities
我正在成功地从 WordPress 网站获取应用程序中的一些数据。一些像“„”这样的实体反应本机不想做类似的引号和我遇到的更多问题。
有什么方法可以在 React Native App 中创建 HTML 实体吗?
提前致谢。
您应该能够使用 html-entities 之类的东西在呈现之前解码文本:
const entities = new Entities();
entities.decode('„') // "„" (double low quotation mark)
如果 'html-entities' README 中使用 require() 的示例对您不起作用,那么这里介绍了如何导入和使用实体的特定子包。
import {Html5Entities} from 'html-entities';
const entities = new Html5Entities();
entities.decode(stringToBeDecoded);
我遇到了同样的问题。我是这样解决的:
首先安装html-实体:
npm 安装 html-entities
在您的代码中:
import {decode} from 'html-entities';
console.log(decode(stringToBeDecoded));
我正在成功地从 WordPress 网站获取应用程序中的一些数据。一些像“„”这样的实体反应本机不想做类似的引号和我遇到的更多问题。
有什么方法可以在 React Native App 中创建 HTML 实体吗?
提前致谢。
您应该能够使用 html-entities 之类的东西在呈现之前解码文本:
const entities = new Entities();
entities.decode('„') // "„" (double low quotation mark)
如果 'html-entities' README 中使用 require() 的示例对您不起作用,那么这里介绍了如何导入和使用实体的特定子包。
import {Html5Entities} from 'html-entities';
const entities = new Html5Entities();
entities.decode(stringToBeDecoded);
我遇到了同样的问题。我是这样解决的:
首先安装html-实体:
npm 安装 html-entities
在您的代码中:
import {decode} from 'html-entities';
console.log(decode(stringToBeDecoded));