項(xiàng)目里的webview JS失效了
反復(fù)檢查了多次后定位在了另外一個(gè)webview切到后臺(tái)時(shí)調(diào)用了下面一句代碼
WebView.pauseTimers()
這句代碼導(dǎo)致了全局的Webview的JS暫停
Webview的onPause()方法官網(wǎng)是這么解釋的:
Does a best-effort attempt to pause any processing that can be paused safely, such as animations and geolocation. Note that this call does not pause JavaScript. To pause JavaScript globally, use? pauseTimers(). To resume WebView, call onResume().?
【翻譯:】通知內(nèi)核嘗試停止所有處理,如動(dòng)畫和地理位置,但是不能停止Js彻秆,如果想全局停止Js岩榆,可以調(diào)用pauseTimers()全局停止Js,調(diào)用onResume()恢復(fù)。