因此,我可以通过以下方法在应用的一部分上加载页面。如果打开的页面有任何区别,则它是Angular 2应用程序。如果我放置一个断点并将该URL复制到模拟器中的chrome中,则该页面可以正常打开,但无法在应用程序中打开。
fun loadInbox() {
inboxView = this.fragmentView!!.findViewById(R.id.webview_inbox)
inboxView!!.webViewClient = object: WebViewClient() {
override fun onPageFinished(view: WebView?, url: String?) {
super.onPageFinished(view, url)
}
}
inboxView!!.settings.javaScriptEnabled = true
val url = "https://test.com/auth?r=m&t=$token"
inboxView!!.loadUrl(url)
}
这是我在Logcat中看到的错误。
06-22 18:31:55.760 13849-13849/com.test I/chromium: [INFO:CONSOLE(1)] "Error: Uncaught (in promise): TypeError: Cannot read property 'getItem' of null
TypeError: Cannot read property 'getItem' of null
at new e (https://www.test.com/main.541c7d5087cbecca24bd.bundle.js:1:23084)
at t.get [as _AuthenticationService_75] (https://www.test.com/main.541c7d5087cbecca24bd.bundle.js:1:2255567)
at t.getInternal (https://www.test.com/main.541c7d5087cbecca24bd.bundle.js:1:2261978)
at t.e.get (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:342908)
at t.injectorGet (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:282705)
at e.get (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:280791)
at t._getByKeyDefault (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:482195)
at t._getByKey (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:481596)
at t.get (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:479963)
at t.injectorGet (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:282705)
at t.createInternal (https://www.test.com/main.541c7d5087cbecca24bd.bundle.js:1:2041133)
at t.createHostView (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:282240)
at t.create (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:103524)
at t.createComponent (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:195584)
at t.activate (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:771819)
at new J (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:833407)
at N (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:830108)
at N (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:829794)
at https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:830622
at t.invokeTask (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:826402)
at Object.onInvokeTask (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:868037)
at t.invokeTask (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:826323)
at n.runTask (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:821843)
at m (https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js:1:829002)", source: https://www.test.com/vendor.1de6bdcb0d523e2b996d.bundle.js (1)
有什么想法吗?我知道我需要启用JavaScript,但据我所知我正确地做到了。
答案 0 :(得分:0)
根据您的评论,我能够扩大搜索范围以查找修复程序,并发现了这个问题:Android API 23. WebView how to ignore javascript errors
他对我的回答的科特林版本是:
inboxView!!.settings.domStorageEnabled = true
用inboxView代替您的Webview。