英文:
.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:
<!-- Images -->
<MauiImage Include="Resources\Images\*" />
Example call in the razor UI:
<MudAvatar Image="resources/images/foo.jpeg" Size="Size.Large" />
I should also mention if I call an external image in the razor UI it works. Following example image loads without any issues:
<MudAvatar Image="https://pbs.twimg.com/profile_images/1313493454710857730/ddYgxm9j_400x400.jpg" Size="Size.Large" />
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的新文件夹。例如:
然后你可以像这样显示图片:
<MudAvatar Image="images/foo.jpeg" Size="Size.Large" />
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论