【问题标题】:React-Native webview window.postMessage just working debug mode on AndroidReact-Native webview window.postMessage 仅在 Android 上工作调试模式
【发布时间】:2019-02-27 10:01:35
【问题描述】:

我已将此 js 注入 webview。 :

var msgP = document.createElement('p');
msgP.setAttribute('id', 'msgLabel');
msgP.setAttribute('style', 'color:red');
msgP.innerHTML = '{0}';    
msgP.onclick = function() {window.postMessage('some Data'); }
document.querySelector('#login-form').appendChild(msgP);

以上代码仅在启用调试模式时有效!

【问题讨论】:

    标签: android react-native webview


    【解决方案1】:

    只需将此行添加到我的 js 的第一行,我的问题就解决了:

    tmpWin = window;
    

    我不知道为什么以及如何解决这个问题。

    【讨论】:

      猜你喜欢
      • 2020-10-12
      • 2015-12-17
      • 1970-01-01
      • 2022-01-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多