使用React Native中的srcset属性渲染图像

时间:2017-11-21 05:43:19

标签: android ios wordpress react-native

我正在从我的一个Wordpress博客中获取JSON提要,我想在JSON提要显示的博客内容中呈现图像。

Feed中只有一个图片,但是你会注意到一个标签,并且在那里还有几个srcset。出于某种原因,给出了一个相对URL,这对我来说无法在Wordpress博客之外渲染图像,但我可以使用标签的属性,即srcset,它提供了图像的绝对路径。

有人可以建议我如何忽略标签的src,而应该能够使用srcset吗?我使用的平台是React Native。

    <p>Can you spare a few minutes to look at some terrible and completely ridiculous life tips? Well then you&#8217;ve come to the right place!</p>\n<p>Some of them come from a sub-Reddit called /r/ShittyLifeProTips, and while they won&#8217;t actually help you to achieve much, they are at least useful when it comes to making us laugh. From using ketchup as a bookmark, to saving yourself precious time by adding toothpaste to meals, these &#8220;pro&#8221; life tips are sure to put a smile on your face while completely failing to help you in any practical way.</p>\n<p>P.S.: These tips are a joke and may be dangerous, don&#8217;t try them yourself!</p>\n<p><strong>#1 Use a toilet seat to put your plate on while watching TV</strong></p>\n<p><img class=\"alignnone size-medium wp-image-2098\" src=\"/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg\" alt=\"\" width=\"284\" height=\"300\" srcset=\"https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-284x300.jpg 284w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV-545x575.jpg 545w, https://vinth.azurewebsites.net/wp-content/uploads/2017/11/1-Use-a-toilet-seat-to-put-your-plate-on-while-watching-TV.jpg 605w\" sizes=\"(max-width: 284px) 100vw, 284px\" /></p>\n<p>&nbsp;</p>\n

0 个答案:

没有答案