加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

React-native 之WebView的使用

发布时间:2020-12-15 08:23:16 所属栏目:百科 来源:网络整理
导读:本系列教程是学习东方耀老师的课程中按照教程写的课堂笔记,基础控件的使用其实与 Android 及 iOS 类似,并没有太大的区别,因此此处只记录代码,不做更多分析,等后期项目实战阶段再详细分析。 代码如下: import React,{Component} from 'react'; import {

本系列教程是学习东方耀老师的课程中按照教程写的课堂笔记,基础控件的使用其实与AndroidiOS类似,并没有太大的区别,因此此处只记录代码,不做更多分析,等后期项目实战阶段再详细分析。

代码如下:


import React,{Component} from 'react';

import {
AppRegistry,
StyleSheet,
Text,
View,
Image,
WebView,
} from 'react-native';
import Dimensions from 'Dimensions';


const width = Dimensions.get('window').width;
const height = Dimensions.get('window').height;


class ReactDemo extends Component {
constructor(props) {
super(props);
}
render() {
return (
<View style={styles.flex}>
<WebView
style={{width:width,height:height}}
source={{uri:'http://www.hao123.com'}}
>
</WebView>
</View>
);
}
}


const styles = StyleSheet.create({
flex:{
flex:1,
},
});


AppRegistry.registerComponent('ReactDemo',() => ReactDemo);



以上是代码,我是用开发iOS版,所以,第一次的时候会报错,解决方案如下:

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读