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

// old

import { WebView } from "react-native";

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

# install
$ yarn add react-native-webview # link
$ react-native link react-native-webview
// new 

import { WebView } from "react-native-webview";

WebView

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

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


/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
*
* @description WebViewIframe
* @augments
* @example
*
*/ import React, {Component} from "react";
import {
StyleSheet,
Dimensions,
Text,
View,
WebView
} from "react-native"; // 获取设备的宽度和高度
let {
height: deviceHeight,
width: deviceWidth
} = Dimensions.get("window"); class WebViewIframe extends Component {
render() {
return (
<View style={styles.container}>
<WebView bounces={false}
scalesPageToFit={true}
source={{
uri:"https://cdn.xgqfrms.xyz",
method: "GET",
}}
style={{
width:deviceWidth,
height:deviceHeight,
}}>
</WebView>
</View>
);
}
} // css-in-js
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop:20
}
}); export default WebViewIframe; export {
WebViewIframe,
};

new version


/**
*
* @author xgqfrms
* @license MIT
* @copyright xgqfrms
*
* @description WebViewIframe
* @augments
* @example
*
*/ import React, {Component} from "react";
import {
StyleSheet,
Dimensions,
Text,
View,
WebView
} from "react-native"; // 获取设备的宽度和高度
let {
height: deviceHeight,
width: deviceWidth
} = Dimensions.get("window"); class WebViewIframe extends Component {
render() {
return (
<View style={styles.container}>
{/* <WebView
bounces={false}
scalesPageToFit={true}
source={{
uri:"https://cdn.xgqfrms.xyz",
method: "GET",
}}
style={{
width: deviceWidth,
height: deviceHeight,
}}>
</WebView> */}
{/* <WebView
bounces={false}
scalesPageToFit={true}
source={{
html: `
<h1 style="color: #0f0;">
WebView & Iframe
</h1>
`,
}}
style={{
width: "100%",
height: 30,
}}>
</WebView> */}
<WebView
bounces={false}
scalesPageToFit={true}
source={{
html: `
<iframe
name="iframeWindow"
src="https://cdn.xgqfrms.xyz"
width="100%"
height="300"
data-dom="iframe"
target="_self"
about:blank
style="border: 1px solid red;"
>
</iframe>
`,
}}
style={{
width: "100%",
height: 300,
}}>
</WebView>
</View>
);
}
} // css-in-js
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop:20
}
}); export default WebViewIframe; export {
WebViewIframe,
};

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. JavaScript夯实基础系列(三):this

      在JavaScript中,函数的每次调用都会拥有一个执行上下文,通过this关键字指向该上下文.函数中的代码在函数定义时不会执行,只有在函数被调用时才执行.函数调用的方式有四种:作为函数调用.作为 ...

  2. 数据结构系列(4)之 B 树

    本文将主要讲述另一种树形结构,B 树:B 树是一种多路平衡查找树,但是可以将其理解为是由二叉查找树合并而来:它主要用于在不同存储介质之间查找数据的时候,减少 I/O 次数(因为一次读一个节点,可以读取 ...

  3. Spring Boot 2.x(十一):AOP实战--打印接口日志

    接口日志有啥用 在我们日常的开发过程中,我们可以通过接口日志去查看这个接口的一些详细信息.比如客户端的IP,客户端的类型,响应的时间,请求的类型,请求的接口方法等等,我们可以对这些数据进行统计分析,提 ...

  4. 【转载】解析 java 按值传递还是按引用传递

    原文链接  说明: (1):“在Java里面参数传递都是按值传递”这句话的意思是:按值传递是传递的值的拷贝,按引用传递其实传递的是引用的地址值,所以统称按值传递. (2):在Java里面只有基本类型和 ...

  5. .net 多线程 Thread ThreadPool Task

    先准备一个耗时方法 /// <summary>/// 耗时方法/// </summary>/// <param name="name">< ...

  6. 解析高德地图api获取省市区,生成最新三级联动sql表

    前言: 最近项目中用到了全国省市区三级信息,但是网上找到的信息都是比较旧的信息.与现在最新的地区信息匹配不上.后来想到高德地图上可能有这些信息.所以解析了一下api接口,生成了相关省市区的sql信息. ...

  7. dubbo-源码分析Consumer

    counsumer使用服务的时候会在xml中配置<dubbo:reference> dubbo在spring.handles里的NamespaceHandle又有如下配置: registe ...

  8. javascript中Date常用方法

    一.Date的构造函数 有四种形式的Date构造函数: //1.构造函数没有参数,则返回当前日期的Date对象 var now=new Date(); //2.构造函数的参数为日期的毫秒数,返回距离1 ...

  9. easyui表格排序

    效果:点击DataGrid表格某个头部,进行升序或降序排序当前页: 问题:对应列设置  sortable:true 没有效果,刚开始以为是对应的列对应的数据库的字段类型有问题, 改动代码,使返回到前台 ...

  10. 模板引擎artTemplate的使用

    1.引入template文件 <script src = js/template-native.js></script> 2.写模板 <script type=" ...