码迷,mamicode.com
首页 > Web开发 > 详细

[React Native] Using the WebView component

时间:2016-08-03 06:41:54      阅读:133      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!