问题标签 [react-native-webview]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
197 浏览

html - 反应原生 webview 静态 HTML 不显示在 Modal 中

我正在尝试在模态视图中呈现 HTML 字符串。

但它没有显示在模态中。有谁知道这个的解决方案?谢谢你。react-native-webView - 5.12.0 react-native - 0.57.8

0 投票
0 回答
152 浏览

react-native - 如何在 react-native 中使用画布创建图形并渲染线的动态坐标?

我试过用 react-native-webview 来做,但我无法让我的坐标到中心。同样,我也无法修复高度和宽度。以下是我的代码,任何建议将不胜感激。我试过用 react-native-webview 来做,但我无法让我的坐标到中心。同样,我也无法修复高度和宽度。以下是我的代码,任何建议将不胜感激。

0 投票
1 回答
1891 浏览

reactjs - React Native WebView 中的 incognito 和 cacheEnabled 道具有什么区别?

首先,我有一个基本的英语水平,所以我希望你能理解。

React Native WebView 中的 incognito 和 cacheEnabled 道具有什么区别?react-native-webview 文档没有详细的解释。

incognito 在 WebView 的生命周期内不存储任何数据。

cacheEnabled 设置 WebView 是否应该使用浏览器缓存。

0 投票
1 回答
6989 浏览

javascript - 使用本地 javascript 反应 Native WebView

我将使用 WebView 创建一个 React Native 应用程序。此视图必须包含本地 HTML 和 Javascript 文件。这是代码。

---> WVView.js

---> index.html

---> 目录

请问,您能建议开发此解决方案的最佳方法吗?当我阅读文档时,我发现诸如 source{{html:...}} 或注入的Javascript 之类的代码用于加载静态本地 javascript。我找不到类似的例子。

现在我无法加载 javascript 文件。谢谢

0 投票
0 回答
381 浏览

react-native - SpeechSynthesis 在 ios 13 上的 react-native-webview 中不起作用

我正在使用 react-native-webview 显示生成的 html 并在 ios 13 上触发 window.speechSynthesis.speak(utterance) 但说话并没有盯着看。React-native:0.60v 代码示例:

var synth = new SpeechSynthesisUtterance(content); window.speechSynthesis.speak(合成器);

0 投票
2 回答
1476 浏览

react-native - 键盘进入时Webview页面不滚动反应本机

我正在使用 react-native-webview 来查看 html。Html 包含像聊天窗口这样的输入框。如果我在 iOS 中为这个 webview 提供 url,它可以正常工作。但是在 android 中,如果我点击输入框键盘重叠在输入框上。

代码:

0 投票
0 回答
86 浏览

react-native - 如何读取本地 css 文件以将其注入 react-native WebView?

在我的 react-native 应用程序中,我想将 css 注入到 react-native 加载的页面中WebView。(我正在显示的在线网站在我的应用程序中看起来应该与WebView正常情况略有不同)

到目前为止,我发现的最有前途的方法是注入 javascript(这可以通过WebView'sinjectedJavaScript属性轻松完成),它执行以下操作:

  1. 将位于我的应用程序的 src 文件夹中的 css 文件(我真的希望它在那里,因为我认为它是我的项目的一部分)读入一个字符串。
  2. 从中生成<style>...</style>标签
  3. 将其写入文档的<head>.

你认为这种方法行得通吗?到目前为止,我无法完成第 1 步。我尝试使用它react-native-fs来读取我的 css 文件,但无法弄清楚如何从我的应用程序的 src 文件夹中访问现有文件。我想我必须以某种方式导出它,所以它最终会出现在RNFS.MainBundlePathor RNFS.DocumentDirectoryPath

0 投票
4 回答
8523 浏览

android - React Native problem: WebView has been removed from React Native

I built new React Native project yesterday using react-native-cli. But when running the project with my android phone, I got this error in red screen.

Invariant Violation: WebView has been removed from React Native. It can now be installed and imported from 'react-native-webview' instead of 'react-native'. See 'https://github.com/react-native-community/react-native-webview'.

I never used WebView and here is my "package.json".

I tried to fix this problem for a whole day but I couldn't. I just think 'react-native-gesture-handler' causes this problem. Anyone who has much experience of React-Native, please help me. Thank you.

0 投票
1 回答
1702 浏览

javascript - 反应本机webview中的EventListener

我试图让滚动事件返回以从 webview 做出反应。根据文档,似乎要走的路是使用 postMessage 和注入的Javascript。

这是我的代码

onMessage 部分似乎正在做某事,因为我在每个滚动事件的日志中都得到了这个,但是没有方向

我错过了什么?

0 投票
0 回答
544 浏览

react-native - 从安全的角度来看,在 React Native 中使用 WebView 好不好?

我正在浏览这个链接,他们提到:

在 WebView 中,页面中的任何恶意代码都与应用程序具有相同的权限。这意味着您需要确保只加载受信任的内容。但还有另一个风险——恶意应用程序也可能访问浏览器内容(如 cookie),并可能窥探密码或拦截 OAuth 代码。

我想知道如果 Facebook 存在安全漏洞,为什么还要实施 WebView。

在 React 原生移动应用程序中使用 WebViews 好吗?