RN Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined错误
发布日期:2022-04-05 00:52:16
浏览次数:3
分类:博客文章
本文共 899 字,大约阅读时间需要 2 分钟。
在使用RN的WebView时有时会弹出:
Setting onMessage on a WebView overrides existing values of window.postMessage, but a previous value was defined 错误的一个界面,关闭后不影响正常使用。
简述下解决方案:
1、在使用WebView的界面添加如下代码
patchPostMessageFunction = function() { var originalPostMessage = window.postMessage; var patchedPostMessage = function(message: any, targetOrigin: string, transfer: Transferable[] | undefined) { originalPostMessage(message, targetOrigin, transfer); }; patchedPostMessage.toString = function() { return String(Object.hasOwnProperty).replace('hasOwnProperty', 'postMessage'); }; window.postMessage = patchedPostMessage; }; patchPostMessageJsCode = '(' + String(this.patchPostMessageFunction) + ')();';
2、WebView中设置injectedJavaScript属性
参考地址:https://github.com/facebook/react-native/issues/10865#issuecomment-269847703
转载地址:https://www.cnblogs.com/lijianyi/p/13530190.html 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
关注你微信了!
[***.104.42.241]2024年04月01日 09时11分06秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
WINCE6.0+S3C2443的启动过程---eboot1
2019-04-27
WINCE5.0+S3C2443系统每隔几分钟会自动关闭LCD显示
2019-04-27
WINCE5.0+2443 camera中断不能进来的原因
2019-04-27
WINCE config.bib文件中的FSRAMPERCENT的意义
2019-04-27
WINCE6.0+S3C2443的启动过程---eboot3
2019-04-27
NK.bin和NK.nb0学习
2019-04-27
WINCE6.0+S3C2443的启动过程---eboot4
2019-04-27
WINCE6.0+S3C2443的启动过程---eboot2
2019-04-27
MMU和cache学习
2019-04-27
S3C2443时钟管理
2019-04-27
WINCE6.0+S3C6410 watchdog重新启动
2019-04-27
WINCE6.0 + S3C2443的启动过程---nboot篇
2019-04-27
nboot通过DNW下载并运行eboot.nb0
2019-04-27
在WinCE 6.0系统下实现USB功能定制
2019-04-27
在WINCE5.0开始菜单中添加应用程序
2019-04-27
WINCE6.0+S3C2443的启动过程---eboot5
2019-04-27
WINCE下如何设置/删除/查询这些环境变量
2019-04-27
WINCE内存机制
2019-04-27
WINCE viewbin命令
2019-04-27