【问题标题】:perform URL redirection within the mobile apps React Native在移动应用程序中执行 URL 重定向 React Native
【发布时间】:2022-01-13 14:17:23
【问题描述】:

我知道 react native 有“链接”功能来执行 url 重定向,这会将用户带到手机的浏览器。有没有什么办法可以在安卓和ios的应用程序内的页面内打开像https://www.google.com/这样的URL?

【问题讨论】:

标签: react-native redirect


【解决方案1】:

是的,您可以使用react-native-webview 库来实现它。您可以为其创建一个组件并在任何您想要的地方使用它。

import React, { Component } from 'react';
import { Text, View } from 'react-native';
import { WebView } from 'react-native-webview';

// ...
class MyWebComponent extends Component {
  render() {
    return <WebView source={{ uri: 'https://www.google.com/' }} />;
  }
}

【讨论】:

    最近更新 更多