首页 > 解决方案 > 如何在 react-native 应用程序中打开网站(Android 和 iOS)

问题描述

我需要在我的 react-native 应用程序中打开网站。需要同时适用于 iOS 和 Android

标签: androidiosreact-native

解决方案


您可以使用WebView组件:https ://facebook.github.io/react-native/docs/webview.html 。

像这样的东西:

import React, { Component } from 'react';
import { WebView } from 'react-native';
class MyWebViewComponent extends Component {
  render() {
     return (
      <WebView
         source={{uri: 'https://google.com'}}
         style={{marginTop: 10}}
      />
    );
  }
}

推荐阅读