首页 > 解决方案 > 如何修复 nativescript 中的图像标签协议错误?

问题描述

我遵循这门课程:https ://courses.nativescripting.com/courses/nativescript-core-getting-started-guide/lectures/2564661 我试图遵循,我的代码是:

<Page loaded="pageLoaded">
  <ActionBar title="My App" class="action-bar"></ActionBar>
  <!-- Your UI components go here -->
  <Image src="~\images\apple.jpg" ></Image>
</Page>

但它没有在android模拟器中显示图片和一些消息错误:

JS: Error in downloadBitmap - java.net.MalformedURLException: no protocol: HellWorld\app\images\apple.jpg

标签: nativescript

解决方案


{N} 中的图像通常使用以下标签进行处理:

src="res://apple"

https://docs.nativescript.org/ui/image-resources


推荐阅读