【问题标题】:how to show json output in html format in react native如何在本机反应中以html格式显示json输出
【发布时间】:2020-01-13 06:56:27
【问题描述】:
"description": "<ul class=\" list-paddingleft-2\" style=\"outline: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; padding: 0px; color: rgb(51, 51, 51); text-align: center; width: 1106.55px;\"><li style=\"outline: 0px; margin: 0px; padding: 0px; list-style: none outside none;\"><div style=\"\"><span style=\"outline: 0px; margin: 0px; padding: 0px; font-size: 14px; line-height: 16.1px;\"><p class=\"MsoNoSpacing\" style=\"text-align: left; \"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\">Mini USB cable is a stylish, sturdy and contemporary way of charging. It is made up of high grade material and offers faster charging &amp; data transfer. The enticing design of this USB is its USP. It is stylish, portable and can even be carried in pocket. The compact design of the Mini USB cable doesn’t acquire much space and doesn’t tangle like the common lengthy cables. This cable has rugged and sturdy build which offers faster charging and effortless data transfer. This product comes with replacement warranty. You can replace the product if you come across any manufacturing defects within the warranty period. Order this product today and carry it in your pocket for charging your Smartphone&nbsp;</span>anywhere anytime.&nbsp;<span style=\"font-family:&quot;Arial&quot;,&quot;sans-serif&quot;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin-bottom: 3.95pt; text-align: justify; line-height: normal; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><b><span lang=\"EN-IN\" style=\"font-family:&quot;Arial&quot;,&quot;sans-serif&quot;;mso-fareast-font-family:&quot;Times New Roman&quot;;\r\ncolor:#C00000;mso-ansi-language:EN-IN\"><br><span style=\"font-size: 14px;\">\r\nOther features</span></span></b><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Soft grip</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Long life span</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Fast charging&nbsp;</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Portable &amp; affordable</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin-bottom: 3.95pt; text-align: justify; line-height: normal; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><b><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif; color: rgb(192, 0, 0);\"><br></span></b></p><p class=\"MsoNormal\" style=\"margin-bottom: 3.95pt; text-align: justify; line-height: normal; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><b><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif; color: rgb(192, 0, 0); font-size: 14px;\">Technical Specifications</span></b><br></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Charging speed: 2A</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Length: 200mm</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p><p class=\"MsoNormal\" style=\"text-align: justify;\"><span style=\"font-size: 14px;\">\r\n\r\n</span><span style=\"font-size: 14px;\">\r\n\r\n</span><span style=\"font-size: 14px;\">\r\n\r\n</span><span style=\"font-size: 14px;\">\r\n</span><span style=\"font-size: 14px;\">\r\n</span><span style=\"font-size: 14px;\">\r\n</span><span style=\"font-size: 14px;\">\r\n</span><span style=\"font-size: 14px;\">\r\n\r\n</span><span style=\"font-size: 14px;\">\r\n\r\n</span></p><p class=\"MsoNormal\" style=\"margin: 0cm 0cm 3.95pt -18pt; text-align: justify; background-image: initial; background-position: initial; background-size: initial; background-repeat: initial; background-attachment: initial; background-origin: initial; background-clip: initial;\"><span lang=\"EN-IN\" style=\"font-family: Arial, sans-serif;\"><span style=\"font-size: 14px;\">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style=\"font-size: 14px;\">Connector type: Micro USB&nbsp;</span></span><span style=\"font-family: Arial, sans-serif;\"><o:p></o:p></span></p></span></div></li></ul>",

这是我的 json 响应,现在我想在我的原生 android 应用程序中显示这个响应,我使用了 html 视图和渲染 html 视图之类的包,首先它显示了错误 -” fontfamily "arial, sans-serif" 不是系统字体,在 react native 中没有通过 font.loadasync 加载" 但是通过搜索我找到了解决方案,但是在此错误之后,现在它的弹出窗口无法将没有瑜伽节点的子节点添加到没有测量功能的父节点!

我应该如何在 html 中显示 json 响应并在本机页面中显示,作为响应它有图像如何做到这一点我被卡住了?

这是我的代码

<Text>
 <HTML html={this.state.data.description} imagesMaxWidth={Dimensions.get('window').width} ignoredStyles={["font-family", "letter-spacing"]}/>
  </Text>

【问题讨论】:

    标签: react-native node-modules jsonresponse


    【解决方案1】:

    您可以使用:react-native-render-html

    【讨论】:

    • 还是一样,我已经使用了渲染 html 包,但错误仍然是一样的?
    • 库会自己处理图片。
    • 如果您的问题是转义字符串,那么您可以根据需要使用unscape 函数。
    • 逆行?你能用例子解释一下吗...!
    • 现在显示错误,无法将没有瑜伽节点的子节点添加到没有度量函数的父节点,现在 data.description 字段为空
    猜你喜欢
    • 2021-06-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-08-31
    • 1970-01-01
    • 2020-06-15
    • 2015-01-30
    • 2021-10-20
    相关资源
    最近更新 更多