【问题标题】:Can I render hole HTML page with react-native-webview?我可以使用 react-native-webview 渲染漏洞 HTML 页面吗?
【发布时间】:2019-04-05 12:33:41
【问题描述】:

所以问题是:我可以使用 react-native-webview 从后面(html 页面)呈现响应吗?

【问题讨论】:

  • 请添加更多细节。你想发布一条消息,然后你可以在 React Native 上下文中阅读吗?您想与 WebView 交互吗?如果是这样,请使用 postMessage,您是否希望在 React Native 中将 HTML 作为字符串获取?你想达到什么目的?
  • 我需要呈现带有确认表单的 html 页面,该确认表单由银行发送以响应我的发布请求。在此表单中,用户必须输入确认码以确认付款

标签: react-native google-pay react-native-webview


【解决方案1】:

我认为这个例子会对你有所帮助 在网络中

<script>
  window.postMessage("Sending data from Web");
</script>
在反应原生
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import { WebView } from 'react-native-webview';

export default class App extends Component {
  
    }

    render() {
        return (
          <WebView
             ref="webview"
             onMessage={this.onMessage}
          />
        );
    }

  onMessage(data) {
  
  alert(data);
}
}

【讨论】:

  • 数据代表什么?
  • 来自网络的响应。
  • 所以现在我需要在这个例子中添加带有 html 的 source prop,对吧?
【解决方案2】:

是的,你可以使用 react-native-webview 渲染整个 html 页面

【讨论】:

  • 如果可能的话,你能提供一个小例子吗?因为我已经尝试过并且总是得到空白的白屏。
  • 我的代码如下所示: return ( ); }
猜你喜欢
  • 2021-01-14
  • 2021-09-05
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-06-07
  • 2015-06-02
  • 1970-01-01
  • 2012-07-04
相关资源
最近更新 更多