npmchenwei111
Version:
test1111
66 lines (55 loc) • 1.37 kB
JavaScript
/**
* Created by chenwei on 2017/8/25.
*
* webview页面
*/
import React, { Component } from 'react'
import { StyleSheet, View, WebView } from 'react-native'
import ActionBar from '../bar/ActionBar'
import PropsUtils from '../utils/PropsUtils'
import StringUtils from '../utils/StringUtils'
class OpenWebViewScreen extends Component {
constructor (props) {
super(props)
let extra = PropsUtils.getExtras(props)
this.state = {
title: extra.title,
url: extra.uri || extra.url
}
}
componentDidMount () {
}
static navigationOptions = ({navigation, screenProps}) => ({
header: null
})
render () {
return (
<View style={styles.container}>
<ActionBar
nav={this.props.navigation}
screenProps={this.props.screenProps}
data={{
title: this.state.title
}}
/>
<WebView
javaScriptEnabled={true}
domStorageEnabled={true}
onNavigationStateChange={(args) => {
if (args.title && !StringUtils.isHttpOrHttps(args.title)) {
this.setState({
title: args.title
})
}
}}
source={{uri: this.state.url}}/>
</View>
)
}
}
const styles = StyleSheet.create({
container: {
flex: 1
}
})
export default OpenWebViewScreen