我可以将本地HTML文件(带有图像和...)加载到WebView
吗?
仅设置Source
参数并不能解决问题。
最佳答案
只要文件是应用程序包的一部分,就可以从文件中加载它,例如:
WebView2.Source = new Uri("ms-appx-web:///assets/text.html");
从WebView.Navigate
WebView can load content from the application’s package using ms-appx-web://, from the network using http/https, or from a string using NavigateToString. It cannot load content from the application’s data storage. To access the intranet, the corresponding capability must be turned on in the application manifest.
对于“随机”文件,我想您可以通过文件选择器提示用户选择文件,然后将其读入字符串并使用NavigateToString,但是根据您要完成的操作,用户体验可能会有些奇怪。
关于windows-8 - 将本地HTML加载到WebView中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13225796/