代码之家  ›  专栏  ›  技术社区  ›  vanngoh

Nativescript Vue-本地映像路径不工作

  •  0
  • vanngoh  · 技术社区  · 8 年前

    在我的 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>
    

    它在Nativescript游乐场上运行良好, <Image /> 你是带着那个 src

    但当我用iOS模拟器在机器上调试时,它不工作了。。。,这个 <图像/> 零件只是一片空白。。。

    项目框架如下所示

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

    有人知道发生了什么吗?非常感谢。

    1 回复  |  直到 8 年前
        1
  •  1
  •   Jen Looper    8 年前

    在NativeScript Vue应用程序中,使用我们的Vue cli模板的预期文件夹结构是将图像放在资产文件夹中。你能试试吗?所以把这个放进去。app/assets/images中的png文件。

    推荐文章