ris*_*apk 4 html entity reactjs react-native
我正在从WordPress网站成功获取应用程序中的一些数据。某些像“&#8222”这样的实体会以原生方式做出反应,而不希望使用类似的引号和我遇到的更多问题。
有什么方法可以在React Native App中使HTML实体正确吗?
提前致谢。
您应该能够在渲染之前使用类似html-entities的功能来解码文本:
const entities = new Entities();
entities.decode('„') // "„" (double low quotation mark)
Run Code Online (Sandbox Code Playgroud)
小智 9
我有同样的问题。这就是我解决它的方法:
首先安装 html-entities :
npm 安装 html 实体
在你的代码中:
import {decode} from 'html-entities';
console.log(decode(stringToBeDecoded));
Run Code Online (Sandbox Code Playgroud)