为 Asset 提供 Url 的 WebView

Provide WebView with Url to Asset

my Uno UWP project 中,我可以查看 html 资产文件(带 Content BuildAction),存储在我的共享项目中,使用以下内容:

   var myAssetUri = new Uri("ms-appx-web:///Assets/Html/index.html");
   myWebView.Navigate(myAssetUri);

但是,这不适用于 Android 或 WASM(尚未在其他平台上尝试过)。在 WASM 上,我得到一个空白页面。在 Android,我收到一个包含消息的页面:

The webpage at ms-appx-web:///Assets/Html/index.html could not be loaded because: net::ERR_UNKNOWN_URL_SCHEME

当我查看两个平台的包文件夹时,我确实找到了我的 html 文件:

所以,我猜我做错了什么......但我不知道那可能是什么。

原因很简单:WebView 尚未在 Wasm 和 Skia 上实现。

这是投资数小时后的解决方案!!

为您的项目编写此行:

var myAssetUri = new Uri("file:///android_asset/Assets/Assets/Html/index.html");

这项工作 100%