ReactNative进阶(十):WebView 应用详解
2.1 通过 url 地址加载网页
import React, {Component} from 'react'; import { AppRegistry, StyleSheet, Dimensions, Text, View, WebView } from 'react-native'; //获取设备的宽度和高度 var { height: deviceHeight, width: deviceWidth } = Dimensions.get('window'); //默认应用的容器组件 class App extends Component { //渲染 render() { return ( {uri:"https://shq5785.blog.csdn.net/",method: 'GET'}} style={{width:deviceWidth, height:deviceHeight}} ); } } //样式定义 const styles = StyleSheet.create({ container: { flex: 1, paddingTop:20 } }); AppRegistry.registerComponent('HelloWorld', () => App);
2.2 加载 html 代码
import React, {Component} from 'react'; import { AppRegistry, StyleSheet, Dimensions, Text, View, WebView } from 'react-native'; //获取设备的宽度和高度 var { height: deviceHeight, width: deviceWidth } = Dimensions.get('window'); //默认应用的容器组件 class App extends Component { //渲染 render() { return ( {html:"
文章版权声明:除非注明,否则均为主机测评原创文章,转载或复制请以超链接形式并注明出处。