大家好,我有一个问题,我把所有文件,如html,css,js放在assets文件夹中,但它没有在webview上显示我。 检查图像。 Index.html file
这就是资产文件夹 Assets
以下是MainActivity中的代码
PhantomJS 1.9.8 (Mac OS X 0.0.0) Service: OntologyService should return the object of ontologies FAILED
Error: Unexpected request: GET https://myurl.com/api/ksearch/ontologies/hbp_data_modality_ontology?size=10000
No more request expected
at $httpBackend (/Users/katkov/WebstormProjects/one-click/bower_components/angular-mocks/angular-mocks.js:1323)
at sendReq (/Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:10761)
at /Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:10470
at processQueue (/Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:14991)
at /Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:15007
at /Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:16251
at /Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:16069
at /Users/katkov/WebstormProjects/one-click/test/spec/services/realontologyservice.js:32
at invoke (/Users/katkov/WebstormProjects/one-click/bower_components/angular/angular.js:4535)
at workFn (/Users/katkov/WebstormProjects/one-click/bower_components/angular-mocks/angular-mocks.js:2517)
undefined
PhantomJS 1.9.8 (Mac OS X 0.0.0): Executed 9 of 9 (1 FAILED) (0.016 secs / 0.158 secs)
答案 0 :(得分:1)
在线搜索您似乎需要在路径网址中使用android_asset
而不是assets
。此外,看起来您的index.html位于另一个名为themes的文件夹下,因此正确的网址为"file:///android_asset/themes/index.html"
。如果我只是错误地查看该图像,那么正确的网址是"file:///android_asset/index.html"
。另外,请使用webView.loadUrl("file:///android_asset/index.html");
,因为您没有正确使用其他方法。 Documentation
答案 1 :(得分:0)
loadDataWithBaseUrl()
有5个参数:baseUrl
,data
,mimeType
,encoding
和historyUrl
。您的应用尝试加载为数据" text / html"与mimeType == utf8
。所有参数都搞砸了。
此方法以另一种方式工作。 WebView没有加载baseUrl
,WebView从第二个参数data
加载一些html。