3 Star 0 Fork 0

Gitee 极速下载/react-native-webview2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/greatbsky/react-native-webview2
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

# react-native-webview2

reactnative Version NPM Version NPM Downloads GitHub issues GitHub stars GitHub license Twitter

This is the WebView or Web component in React Native both for Android and iOS, support auto height & call js (not support on ios) between component and html document, very useful & easily!

This is a JavaScript-only implementation of WebView in React Native, named react-native-webview2 or WebView or Web.

  1. react-native-webview2 can change the height of WebView dynamically when you set the prop source={uri:xxx}(until now not yet support html) if you not set the prop style={height:xxx}, otherwise the height of WebView is fixed.
  2. react-native-webview2 also can make you call js in html document or reactnative, if you want to call js in html page from react-native, you just invoke this.web.evalJs("js code...here") from react-native. If you want to call react-native code, you just invoke returnEval("rn code...here") from html page, meanwhile set the prop evalReturn={((r) => {eval(r)}).bind(this)}.
  3. react-native-webview2 support all props of WebView in React Native.

WebView demo project: https://github.com/greatbsky/react-native-webview2-demo

WebView Demo

WebView Usage

  1. Run npm install react-native-webview2@latest --save
  2. Code like this:
import Web from 'react-native-webview2';

<Web
  ref={(c) => {this.web = c}}
  evalReturn={((r) => {eval(r)}).bind(this)}
  source={{uri: 'xxx'}}
  style={[styles.web, {minHeight: 300}]}
  ...other props
  />
  1. Full demo code: https://github.com/greatbsky/react-native-webview2-demo/blob/master/WebView2App/app.js

WebView configuration

special props for WebView

  • evalJs: (not support on ios) handle function if you want to call js in html page from react-native. eg: this.web.evalJs('var t = document.title; alert(t)');
  • evalReturn: require if you need call js fun in react-native from html page. evalReturn={((r) => {eval(r)}).bind(this)}.
  • go: handle function if you need open a new uri. eg: this.web.go('http://xxxxxx');

other

  • returnEval: js function in html page if you want to call js in react-native from html page, eg:returnEval('this.setText("from html page...")'), usually you also need set the prop of component evalReturn={((r) => {eval(r)}).bind(this)}

Licensed

MIT License

中文说明请参见

https://github.com/greatbsky/react-native-webview2/wiki

MIT License Copyright (c) 2016 greatbsky Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

本项目是WebView 或 Web 组件,支持Android、iOS, 支持auto height高度自适应及在html页面和RN组件之间call js相互调用js方法,very 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者 (2)

全部

近期动态

接近5年前创建了仓库
不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/mirrors/react-native-webview2.git
git@gitee.com:mirrors/react-native-webview2.git
mirrors
react-native-webview2
react-native-webview2
master

搜索帮助