.NET MAUI Blazor混合本地图像未加载。

huangapple go评论97阅读模式
英文:

.NET MAUI Blazor Hybrid local images not loading

问题

在.NET MAUI Blazor Hybrid项目中使用MudBlazor进行UI开发。目前,我的应用程序中无法加载图像。我在项目文件中声明了以下内容:

<!-- 图像 -->
<MauiImage Include="Resources\Images\*" />

在Razor UI中的示例调用:

<MudAvatar Image="resources/images/foo.jpeg" Size="Size.Large" />

我还应该提到,如果我在Razor UI中调用外部图像,它可以正常工作。以下示例图像可以正常加载,没有任何问题:

<MudAvatar Image="https://pbs.twimg.com/profile_images/1313493454710857730/ddYgxm9j_400x400.jpg" Size="Size.Large" />

我正在Android模拟器中测试应用程序,并确认了图像属性的构建操作设置为MauiImage。我是否漏掉了什么?提前感谢您的帮助!

英文:

Working on a .NET MAUI Blazor Hybrid and using MudBlazor for my UI. Images are currently not loading in my app. I have the following declared in the project file:

&lt;!-- Images --&gt;
&lt;MauiImage Include=&quot;Resources\Images\*&quot; /&gt;

Example call in the razor UI:

&lt;MudAvatar Image=&quot;resources/images/foo.jpeg&quot; Size=&quot;Size.Large&quot; /&gt;

I should also mention if I call an external image in the razor UI it works. Following example image loads without any issues:

&lt;MudAvatar Image=&quot;https://pbs.twimg.com/profile_images/1313493454710857730/ddYgxm9j_400x400.jpg&quot; Size=&quot;Size.Large&quot; /&gt;

I am testing the app in the Android Emulator and confirmed the image properties Build Action is set to MauiImage.

Am I missing something? Thanks in advance!

答案1

得分: 1

你可以尝试在项目的wwwroot文件夹下创建一个名为images的新文件夹。例如:

.NET MAUI Blazor混合本地图像未加载。

然后你可以像这样显示图片:

&lt;MudAvatar Image=&quot;images/foo.jpeg&quot; Size=&quot;Size.Large&quot; /&gt;
英文:

You can try to create a new folder named images below the project's wwwroot folder. Such as:

.NET MAUI Blazor混合本地图像未加载。

And then you can display the image such as:

&lt;MudAvatar Image=&quot;images/foo.jpeg&quot; Size=&quot;Size.Large&quot; /&gt;

huangapple
  • 本文由 发表于 2023年1月9日 10:48:45
  • 转载请务必保留本文链接:https://go.coder-hub.com/75052765.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定