Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Nativescript-Vue -- Local image path not working

In my App.vue

<template>
  <Page class="page">       
        <ActionBar title="my-app" class="top-nav" />
        <ListView v-show="showHome" for="(post, index) in posts" @itemTap="onItemTap" row="1">
            <v-template>
              <FlexboxLayout flexDirection="row" class="post-list" justifyContent="space-between">
                <FlexboxLayout flexDirection="column" width="15%" justifyContent="space-between" alignItems="center">
                  <Image src="~/images/up.png" @tap="onButtonTap('up', index)" class="up-down" />
                  <Label :text="post.score" class="post-count" />
                  <Image src="~/images/down.png" @tap="onButtonTap('down', index)" class="up-down" />
              </FlexboxLayout>
            </v-template>
        </ListView>
    </Page>
</template>

It works very well on Nativescript Playground, <Image /> did show up with the src

But when I debug on machine with an iOS simulator, it's not working..., the <Image /> parts are just a blank...

The project skeleton is shown as below

/app
|_ app.js
|_ app.css
|_ package.json
|_ /components
|   |_App.vue
|
|_ /images
    |_up.png

Anyone know what's going on? Thank you.

like image 901
vanngoh Avatar asked Dec 28 '25 22:12

vanngoh


1 Answers

in a NativeScript-Vue app, the expected folder structure using our vue-cli template is to put your images in an assets folder. Can you give that a try? So put the .png files in app/assets/images.

like image 170
Jen Looper Avatar answered Dec 30 '25 22:12

Jen Looper



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!