UWP和Windows Phone 8.1上的Xamarin.Forms中的Webview BaseURL
发布时间:2020-12-14 01:38:05 所属栏目:Windows 来源:网络整理
导读:在我的共享便携式Xamarin项目中,这适用于UWP,Windows Phone 8.1和Windows 8.1: HtmlWebViewSource htmlSource = new HtmlWebViewSource();htmlSource.Html = @"htmlbodyimg src='ms-appx-web:///Assets/somePicture.png' //body/html";htmlSource.BaseUrl =
在我的共享便携式Xamarin项目中,这适用于UWP,Windows Phone 8.1和Windows 8.1:
HtmlWebViewSource htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><img src='ms-appx-web:///Assets/somePicture.png' /></body></html>"; htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get(); WebView webView = new WebView { Source = htmlSource,}; 显然,这不是跨平台(iOS和Android).我想要这个,但它不适用于UWP,Windows Phone 8.1和Windows 8.1: HtmlWebViewSource htmlSource = new HtmlWebViewSource(); htmlSource.Html = @"<html><body><img src='somePicture.png' /></body></html>"; htmlSource.BaseUrl = DependencyService.Get<IBaseUrl>().Get(); WebView webView = new WebView { Source = htmlSource,}; IBaseUrl: public interface IBaseUrl { string Get(); } UWP,Windows Phone 8.1和Windows 8.1的BaseUrl实现取自Windows Phone 8.0 sample project: [assembly: Dependency(typeof(MyApp.UWP.BaseUrl))] namespace MyApp.UWP { public class BaseUrl : IBaseUrl { public string Get() { return ""; // "ms-appx-web:///Assets/" doesn't work } } } 我尝试了返回“ms-appx-web:/// Assets /”,“ms-appx-web:///”的BaseUrl的不同变体,将文件放在项目根目录或“Assets”目录中什么都行不通 据我所知,这曾经适用于Windows Phone 8.0. 解决方法
从Xamarin Forms 2.3.1开始,用于Windows RT的WebViewRenderer只是忽略了BaseUrl(
https://github.com/xamarin/Xamarin.Forms/blob/2.3.1/Xamarin.Forms.Platform.WinRT/WebViewRenderer.cs#L26).但是,在2.3.2分支上有一个修复:
https://github.com/xamarin/Xamarin.Forms/blob/2.3.2/Xamarin.Forms.Platform.WinRT/WebViewRenderer.cs
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- windows – 是否有像PeekMessage这样的函数不处理消息?
- 在Wix中创建自定义操作以用于静默安装
- windows – 如何从命令行获取文件的所有权?
- 如何在Windows环境中使用Mahout?
- windows-server-2016 – 在Windows Server 2016上为用户锁定
- 这个编辑器在Windows 10 cmd中由“git commit –amend”打开
- active-directory – 如何在不访问域(控制器)的情况下删除组
- winapi – 在Win32中GDI功能BitBlt和StretchBlt硬件加速了吗
- 如何在StandardStyles.xaml中定义基元
- 使用托管服务帐户启动Windows docker容器时出错
推荐文章
站长推荐
- windows – 64位和32位注册表之间有区别吗?
- windows-server-2003 – 如何强制用户在登录时回
- go – uint64是否需要8个字节的存储空间?
- windows – 通过命令行更改注册表项的权限
- 天蓝色 – 如何报告Windows Server Service Bus中
- windowsServer-------- 系统中调出文件扩展名
- windows环境:idea或者eclipse指定用户名操作had
- 可执行文件在Windows上以Mono内置
- windows – Haskell,GHC,win32,cairo
- signalr – Microsoft.Owin类似OwinMiddleware和
热点阅读