首页 > Web开发 > 详细

[React Native] Using the WebView component

时间:2016-08-03 06:39:40      阅读:288      评论:0      收藏:0      [点我收藏+]

We can access web pages in our React Native application using the WebView component. We will connect the links in our repository component to their Github web page when a user click on them.

 

Navigate to WebView component:

    openPage(url){
        this.props.navigator.push({
            component: Web,
            title: Web View,
            passProps: {url}
        });
    }

 

Web View Compnent:

import React from react;
import {
    View,
    WebView,
    StyleSheet
} from react-native;

var styles = StyleSheet.create({
    container: {
        flex: 1,
        backgroundColor: #F6F6EF,
        flexDirection: column,
    },
});

class Web extends React.Component{
    render(){
        return (
            <View style={styles.container}>
                <WebView source={{uri: this.props.url}} />
            </View>
        );
    }
}

Web.propTypes = {
    url: React.PropTypes.string.isRequired
};

module.exports = Web;

 

[React Native] Using the WebView component

原文:http://www.cnblogs.com/Answer1215/p/5731336.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!