Loading Local HTML with WebView Xamarin Forms

前端 未结 5 1076
离开以前
离开以前 2021-01-19 20:11

I am trying to load a local HTML page in a webview with Xamarin forms. I am using the basic example in the dev docs although I can get a URL to load I can\'t get my own HTML

5条回答
  •  后悔当初
    2021-01-19 20:35

    WebView.BaseUrl only tells the WebView where to start looking for files. It's the root folder of the "web site". By default browsers will load the file index.html, so if you rename your file to index.html I believe it should load automatically.

    I think this should be possible too:

    webviewjava.BaseUrl = DependencyService.Get().Get();
    webviewjava.Source = "TestWebPage.html";
    

    Here you're saying "use this location as the default place to look for files" and "look up this file and use it as the source for the HTML".

提交回复
热议问题