![](/img/trans.png)
[英]Javascript is not working in React-Native WebView for Android (javaScriptEnabled = true is set)
[英]React-Native webview window.postMessage just working debug mode on Android
我已經將此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);
上面的代碼僅在啟用調試模式時有效!
只需將這行添加到我的js的第一行即可解決我的問題:
tmpWin = window;
我不知道為什么以及如何解決這個問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.