标签:
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