寻找用户可以解雇的React Native的弹出式webview(Android)

时间:2017-03-14 02:13:57

标签: webview react-native

我需要打开一个用户可以轻易解雇的网页视图 它应该能够显示给定的URL,并且有一个简单的解除选项(如x按钮) - 导航按钮,也应该显示。

我抬头看Awesome React Native然后找不到那样的东西。

2 个答案:

答案 0 :(得分:1)

您可以将React Native WebView组件与View包装器一起使用来实现它。像这样创建自己的MyWebView组件:

class MyWebview extends React.Component{
  constructor(props, context) {
    super(props);
    this.goBack = this.goBack.bind(this);
  }

  goBack() {
    this.props.navigator.pop();
  }

  render() {
    if (!this.props) {
      return null;
    }else{
      return (
        <View style={[GlobalStyle.container, style.container]}>
          <NavigationBar  />

          <WebView
            startInLoadingState={true}
            source={{uri: this.props.route.url}}
          />
        </View>
      );
    }
  }
}

MyWebview.propTypes = {
  navigator: PropTypes.object,
  route: PropTypes.object
};

export default MyWebview;

您可以在路线功能中将URL作为参数传递:

let passObj = Object.assign({}, Routes.MyWebview, {
  url: url
});
this.props.navigator.push(passObj);

答案 1 :(得分:0)

试试这个react-native-custom-tabs

对我来说效果很好。