只要文件是应用程序包的一部分,您就可以从文件加载它,例如:
原文链接:/windows/364300.htmlWebView2.Source = new Uri("ms-appx-web:///assets/text.html");
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,但根据你想要完成的内容,用户体验可能有点奇怪.