在 WebView 中显示本地图像 windows phone 8.1

Show local images inside WebView windows phone 8.1

我正在尝试在 WP8.1 应用程序的 Webview 中加载 html 文件。我将图像存储在我的项目中。当我 运行 浏览器中的 html 文件时,它 运行 是正确的,但是当我在 Webview 中加载这个 html 文件时,它不显示图像,当我转换HTML 文件的内容,并尝试 NavigateToString 方法。这是我的代码

<!DOCTYPE html>
   <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <meta charset="utf-8" />
      <title></title>
      <style>
        table, th, td {
            border: 0px;
        }
     </style>
    </head>
    <body>
    <table>
        <tr>
            <img src="ms-appx:///discount_icon.jpg" alt="Smiley face" height="200" width="400" />
        </tr>
        <tr>
            <td>
                        <div align="Left" style="width: 100%;">
                            <div style="width: 70%; float: left;"><b> Left </b>    </div>

                            <div align="right" style="width: 30%; float: right;">
                                <div align="right" style="position: relative;  padding-top:10px; background-image: url('ms-appx:///discount_icon.jpg');background-size:cover; background-repeat:no-repeat; height:36px; width: 85px; font-weight: bold; color: black;"><span style="text-align:center;color:white; margin-right:27px;margin-top:15px">5%</span></div>
                            </div>

                            <div style="width: 70%; float: left;"> From <span style="background-color:#01A9DB;padding:2px;">0.00</span> values </div>

                        </div>
           </td>
        </tr>
        <tr>
            <td>February</td>
        </tr>
    </table>
     </body>
    </html>

有人可以帮忙吗?

您不需要在 html 图片来源中的图片名称前加上 ms-appx:///

如果你在 html 的同一个文件夹中有图像,代码将是这样的:

<img src="test.png" style="width:100%; height:100%;" />

您可以尝试 NavigateToLocalStreamUri。你可以 google 它。有很多关于该功能的示例。