React Native & iframe & WebView

React Native 怎么渲染 iframe 页面

WebView & source html

https://facebook.github.io/react-native/docs/webview#source

https://facebook.github.io/react-native/docs/webview.html#html

  1. // old
  2. import { WebView } from "react-native";

https://github.com/react-native-community/react-native-webview

  1. # install
  2. $ yarn add react-native-webview
  3. # link
  4. $ react-native link react-native-webview
  1. // new
  2. import { WebView } from "react-native-webview";

WebView

https://reactscript.com/tag/iframe/

http://www.hangge.com/blog/cache/detail_1564.html


  1. /**
  2. *
  3. * @author xgqfrms
  4. * @license MIT
  5. * @copyright xgqfrms
  6. *
  7. * @description WebViewIframe
  8. * @augments
  9. * @example
  10. *
  11. */
  12. import React, {Component} from "react";
  13. import {
  14. StyleSheet,
  15. Dimensions,
  16. Text,
  17. View,
  18. WebView
  19. } from "react-native";
  20. // 获取设备的宽度和高度
  21. let {
  22. height: deviceHeight,
  23. width: deviceWidth
  24. } = Dimensions.get("window");
  25. class WebViewIframe extends Component {
  26. render() {
  27. return (
  28. <View style={styles.container}>
  29. <WebView bounces={false}
  30. scalesPageToFit={true}
  31. source={{
  32. uri:"https://cdn.xgqfrms.xyz",
  33. method: "GET",
  34. }}
  35. style={{
  36. width:deviceWidth,
  37. height:deviceHeight,
  38. }}>
  39. </WebView>
  40. </View>
  41. );
  42. }
  43. }
  44. // css-in-js
  45. const styles = StyleSheet.create({
  46. container: {
  47. flex: 1,
  48. paddingTop:20
  49. }
  50. });
  51. export default WebViewIframe;
  52. export {
  53. WebViewIframe,
  54. };

new version


  1. /**
  2. *
  3. * @author xgqfrms
  4. * @license MIT
  5. * @copyright xgqfrms
  6. *
  7. * @description WebViewIframe
  8. * @augments
  9. * @example
  10. *
  11. */
  12. import React, {Component} from "react";
  13. import {
  14. StyleSheet,
  15. Dimensions,
  16. Text,
  17. View,
  18. WebView
  19. } from "react-native";
  20. // 获取设备的宽度和高度
  21. let {
  22. height: deviceHeight,
  23. width: deviceWidth
  24. } = Dimensions.get("window");
  25. class WebViewIframe extends Component {
  26. render() {
  27. return (
  28. <View style={styles.container}>
  29. {/* <WebView
  30. bounces={false}
  31. scalesPageToFit={true}
  32. source={{
  33. uri:"https://cdn.xgqfrms.xyz",
  34. method: "GET",
  35. }}
  36. style={{
  37. width: deviceWidth,
  38. height: deviceHeight,
  39. }}>
  40. </WebView> */}
  41. {/* <WebView
  42. bounces={false}
  43. scalesPageToFit={true}
  44. source={{
  45. html: `
  46. <h1 style="color: #0f0;">
  47. WebView & Iframe
  48. </h1>
  49. `,
  50. }}
  51. style={{
  52. width: "100%",
  53. height: 30,
  54. }}>
  55. </WebView> */}
  56. <WebView
  57. bounces={false}
  58. scalesPageToFit={true}
  59. source={{
  60. html: `
  61. <iframe
  62. name="iframeWindow"
  63. src="https://cdn.xgqfrms.xyz"
  64. width="100%"
  65. height="300"
  66. data-dom="iframe"
  67. target="_self"
  68. about:blank
  69. style="border: 1px solid red;"
  70. >
  71. </iframe>
  72. `,
  73. }}
  74. style={{
  75. width: "100%",
  76. height: 300,
  77. }}>
  78. </WebView>
  79. </View>
  80. );
  81. }
  82. }
  83. // css-in-js
  84. const styles = StyleSheet.create({
  85. container: {
  86. flex: 1,
  87. paddingTop:20
  88. }
  89. });
  90. export default WebViewIframe;
  91. export {
  92. WebViewIframe,
  93. };

https://github.com/archriss/react-native-render-html

https://stackoverflow.com/questions/53736424/how-to-render-html-table-in-react-native

Render HTML in React Native

https://stackoverflow.com/questions/29334984/render-html-in-react-native

React Native & iframe & WebView的更多相关文章

  1. react native 中webview内的点击事件传到外部原生调用

    先说一下我使用webview的时候遇到的一个功能需求 是这样的,上图中的这个页面是用h5做的,但是由于点击"我的优惠劵"是需要跳转到我原生的页面,也就是说我需要获得这个h5提供的点 ...

  2. React Native WebView关闭缓存

    React Native WebView关闭缓存 网上搜索没有找到关闭React Native下webview控件的缓存的方法,经测试找到解决方案,记录如下 核心思路:通过请求时设置请求头,使页面缓存 ...

  3. 基于webview的Hybrid app和React Native及html5

    基于webview的Hybrid app和React Native及html5 React Native 结合了 Web 应用和 Native 应用的优势,可以使用 JavaScript 来开发 iO ...

  4. [React Native] Using the WebView component

    We can access web pages in our React Native application using the WebView component. We will connect ...

  5. React Native组件介绍

    1.React Native目前已有的组件 ActivityIndicatorIOS:标准的旋转进度轮; DatePickerIOS:日期选择器: Image:图片控件: ListView:列表控件: ...

  6. react native 入门实践

    上周末开始接触react native,版本为0.37,边学边看写了个demo,语法使用es6/7和jsx.准备分享一下这个过程.之前没有native开发和react的使用经验,不对之处烦请指出.希望 ...

  7. React Native Changed the World? or Nothing.

    RN是一个awesome的技术, facebook很有想法的团队创造出一项新的技术改变了native开发界. 但是RN本身又疑点重重, RN是为了解决什么问题而存在的? 在诞生了一年后, RN又解决了 ...

  8. 30天React Native从零到IOS/Android双平台发布总结

    前言 本人有近十年的技术背景,除了APP开发之外对后端.前端等都比较熟悉,近期做一个APP项目需要IOS.Android两个平台都需要,只能硬着头皮上.其实很早就想开发APP也很早就接触Android ...

  9. React Native系列文章

    React Native版本升级的正确姿势 WebView JS与RN进行通讯 用API网关把API管起来 React-Native 给客户端来个「同音词模糊搜索」 30天React Native从零 ...

随机推荐

  1. 在github上搭建一个静态的个人网站

    说一下大概步骤 1.创建一个新仓库 仓库名必须是你的用户名+github.io后缀 例:用户名:tom 仓库名就要是:tom.github.io (这里具体步骤可以自己百度一下) 2.创建好仓库我们该 ...

  2. [开发技巧]·HTML检测输入已完成自动填写下一个内容

    [开发技巧]·HTML检测输入已完成自动填写下一个内容 个人网站 --> http://www.yansongsong.cn 在上一个博客中简易实现检测输入已完成,我们实现了检测输入已完成,现在 ...

  3. 2.4配置的热更新「深入浅出ASP.NET Core系列」

    希望给你3-5分钟的碎片化学习,可能是坐地铁.等公交,积少成多,水滴石穿,谢谢关注. 大家知道通常我们修改网站的配置文件比如,webconfig的时候,网站需要重启才能读取到最新的修改,所谓热更新就是 ...

  4. Spring Cloud Alibaba到底坑不坑?

    之前我发过一篇<说说我为什么看好Spring Cloud Alibaba>,然后这两天有网友给我转了这篇文章<坑爹项目spring-cloud-alibaba,我们也来一个>, ...

  5. React-代码复用(mixin.hoc.render props)

    前言 最近在学习React的封装,虽然日常的开发中也有用到HOC或者Render Props,但从继承到组合,静态构建到动态渲染,都是似懂非懂,索性花时间系统性的整理,如有错误,请轻喷~~ 例子 以下 ...

  6. docker 安装 MySQL 8,并减少内存占用 记录

    目前vps 1cpu 512m内存 MySQL内存占用77% ,约350m ,经过修改配置文件优化后如下 $ ps aux 进入docker bash $ docker exec -it pwc-my ...

  7. 【Json】fastjson与jackson常用操作记录

    本文只是记录fastjson.jackson一些常用的操作方法,没作比较,网上写比较的文章很多啦. 1.对象转Json串 // fastjson String objStr = JSON.toJSON ...

  8. javaweb中上传视频,并且播放,用上传视频信息为例

    1.上传视频信息的jsp页面uploadVideo.jsp <body background="image/bk_hero.jpg"><div id=" ...

  9. 第八课 表格 html5学习3

    表格用来处理表格式数据的,不是用来布局的. 一.基本语法格式 <table> <tr> 行标签 <td></td> 单元格标签 </tr> ...

  10. Easyui datagrid combobox输入框下拉(取消)选值和编辑已选值处理

    datagrid combobox输入框下拉(取消)选值和编辑已选值处理 by:授客 QQ:1033553122 测试环境 jquery-easyui-1.5.3   需求场景 如下,在datagri ...