问题描述
我有一个 react native 应用程序(使用 react-native 0.43.3),它使用 webview 来显示用于网上银行的网页.该站点加载一个带有登录页面的弹出窗口.
I have a react native application(using react-native 0.43.3) that uses webview to show a web page used for online banking. That site loads a popup window with the login page.
使用 ReactNative WebView 这个弹出窗口没有显示.在原生 android 中启用弹出窗口显示我发现我需要制作 webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)
,但在使用 ReactNative WebView 时找不到设置此参数的方法.
With the ReactNative WebView this popup window in not shown. In native android to enable popup window showing I found out that I need to make webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true)
, but couldn't found a way to set this parameter when using ReactNative WebView.
有没有办法使用 ReactNative 提供的 WebView 来实现这一点?
Is there a way which I can achieve this with the WebView provided with ReactNative?
推荐答案
前段时间我需要 fork react-native 框架,因为在 iOS WebView
之间使用 javaScript 桥接时存在一个 bugreact-native 和 native(iOS 和 Android),经过一些研究,我得出的结论是,我必须分叉 repo 才能修复它,所以我这样做了.一周前,我还需要 webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(boolean)
方法,所以我继续将它与 view.getSettings().setSupportZoom(boolean)
和 view.getSettings().setSupportMultipleWindows(supports)
.
A while back I needed to fork the react-native framework because there is a bug in the iOS WebView
when using javaScript bridge between react-native and native (iOS and Android), after some research I came to the conclusion that I must fork the repo in order to fix it so I did.A week ago I needed the webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(boolean)
method as well, so I went ahead and added it in my fork along with view.getSettings().setSupportZoom(boolean)
and view.getSettings().setSupportMultipleWindows(supports)
.
如果你愿意,这是我的叉子.请记住,这意味着您需要从源代码为 android 构建 react-native,可以找到有关此事的更多信息 这里,老实说这有点麻烦,但在某些情况下这是值得的.fork 来自 react-native 0.44.0,你还应该记住,如果你使用我的 fork,这意味着当它们出现时你可能无法更新版本,所以这最终取决于你的需求,最坏的情况是你总是可以 fork 我的 fork 并将其与最新版本合并.
If you want, here is my fork.Please keep in mind that it means that you need to build react-native for android from source, more info on the matter can be found here, it's a bit of a hustle to be honest, but in some cases it's worth it.the fork is from react-native 0.44.0, you should also keep in mind that if you use my fork, in means you probably wont be able to update version when they do come out, so it all depends on your needs in the end, worst case scenario you could always fork my fork and merge it with the newest version.
您可以通过修改 package.json
文件然后运行 npm update react-native
you can fetch my fork with npm by modifying you package.json
file and then running npm update react-native
"dependencies": {
//...
"react-native": "samermurad/react-native#rctWebView-legacy-fix",
//...
}
我打算提取修复程序并构建一个单独的 WebView 组件,但我目前太忙了:/
I am planning to extract the fixes and build a separate WebView component, but I am currently too busy for that :/
希望有帮助:)
这篇关于在 React Native WebView 中启用弹出窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!