Jonas
Jonas

Reputation: 7885

NativeScript Image with path won't load but url works fine

My NativeScript Image is not showing when I use a a path to a file. My code currently looks like this:

<StackLayout>
    <Image src="~/assets/logo"></Image>
    <Image src="https://play.nativescript.org/dist/assets/img/NativeScript_logo.png"></Image>
</StackLayout>

The lower Image using a url is showing up but the one above isn't.

I also tried these:

    <Image src="/assets/logo.png"></Image>
    <Image src="../assets/logo.png"></Image>
    <Image src="../../assets/logo.png"></Image>  

And other options but nothing works.

I have a folder assets inside my app folder and inside I have a logo.png picture, which is the picture from the url above.

Also I don't get any console message, that it can't find my file.

Any Ideas?

Upvotes: 0

Views: 944

Answers (2)

Raditya Syahrozi
Raditya Syahrozi

Reputation: 11

it should contain extension name

 <Image src="~/assets/logo.png"></Image>

Upvotes: 0

ogrodowiczp
ogrodowiczp

Reputation: 21

Supposing your structure looks like this:

app/ assets/ logo.png components/ ... app.component.ts ...

I'd recommend trying: <Image src="~/assets/logo.png"></Image>

~/ means you're looking in home directory of your project.

Check if app is actually your home directory. It might be src above app. Then you'd need to go for ~/app/asset/...

Upvotes: 1

Related Questions