在webview中未加载本地相对图像。 UWP窗口10 [英] Local relative images are not loading in webview. UWP windows 10

查看:135
本文介绍了在webview中未加载本地相对图像。 UWP窗口10的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试使用存储在Windows 10应用程序的LocalStorage文件夹中的NavigateToString来加载html时。它没有加载它的相关文件,如CSS,Javascript,Images。



我也在顶部使用了基本标签。相同的概念适用于Silverlight应用程序。



请帮助我。



我是什么尝试过:



使用NavigateToString在WebView中导航。 HTML文件存储在LocalStorage文件夹中。

When I am trying to Load an html using NavigateToString stored in LocalStorage folder of Windows 10 application. It is not loading its relative files like CSS, Javascript, Images.

I have used base tag on the top as well. Same concept works for Silverlight application.

Please help me on this.

What I have tried:

Used NavigateToString for navigating in WebView. The HTML files are stored in LocalStorage folder.

推荐答案

hi Mohitdb7

考虑这些:

1.you无法直接在本地文件夹下启动html文件(出于安全原因),但您可以从本地文件夹的子文件夹中启动html文件

例如:ms-appdata:///local/subfolder/my.html可以启动来自webview。



2.你的其他数据(图片等)现在可以使用相对于你的html文件的地址。



3.你需要使用navigatetolocalstreamuri和buildlocalstreamuri以及解析器在javascript和native之间进行交互(当从localstorage启动时)

你现在可以参考这个链接更多关于第3点。 WebView.NavigateToLocalStreamUri方法 - Windows应用开发 [ ^ ]。



希望它有所帮助。
hi Mohitdb7
consider these:
1.you cant launch html file present directly under localfolder (security reasons) but you can launch html files from inside subfolders of localfolder
eg: ms-appdata:///local/subfolder/my.html can be launched from webview.

2.your other data (images etc.) will work now with address relative to your html file.

3.you need to use navigatetolocalstreamuri and buildlocalstreamuri along with resolver to interact between javascript and native (when launching from localstorage)
you can refer to this link to now more about point 3. WebView.NavigateToLocalStreamUri method - Windows app development[^].

hope it helps.


这篇关于在webview中未加载本地相对图像。 UWP窗口10的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆