【问题标题】:unable to display list of items with Nativescript-Vue GridLayout无法使用 Nativescript-Vue GridLayout 显示项目列表
【发布时间】:2019-12-07 03:27:15
【问题描述】:

Nativescript-vue 新手在这里...

我正在使用 nativescript-vue 来显示项目列表。当 .vue 页面加载时,网格应该只是一个空表。单击按钮时,网格中会填充我从服务中检索到的列表的子元素。我遇到了两个问题:

  1. 只有一行,列表中的每个项目都应该有一行。

  2. 日期将是日期元素,例如 06-01-2019 11:30:01,但我更愿意将其显示为 06-01-2019

在我的 *.vue 中:

 <RadListView for="item in itemList" layout="grid" @itemTap="onItemTap">
   <v-template>
       <GridLayout rows="20, 20" class="list-item list-item-grid">
           <GridLayout row="1" rows="25, 35" columns="auto, auto, auto, auto">
             <Label col="0" :text="item.date" class="list-item-left" textWrap="true"verticalAlignment="middle" horizontalAlignment="left"></Label>
              ....
           </GridLayout>
        </GridLayout>
    </v-template>
 </RadListView>
....
<script>
  expot default {

        data() {
            return {               
                itemList: []
            };
        },
        methods: { 
           getItems() {
             // really simplified but it will return something like:
              // [{"date" :"09-01-2019 11:32:01", "name":" first last"}]
            service.getItemArray()
           }
        },
         beforeMount: function() {
            this.itemList= this.getItems();
         }
</script>

我放了一个缩短的 Playground 版本here

【问题讨论】:

标签: nativescript-vue


【解决方案1】:

您可以尝试在单击按钮后使用v-if 来渲染 RadListView,或者手动使用load on demand

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2020-03-15
    • 1970-01-01
    • 2021-02-20
    • 2021-08-09
    • 2018-06-13
    • 1970-01-01
    • 1970-01-01
    • 2020-09-22
    相关资源
    最近更新 更多