【问题标题】:How to read [object Object] in RadListView using NativeScript-vue如何使用 NativeScript-vue 在 RadListView 中读取 [object Object]
【发布时间】:2019-09-02 14:03:34
【问题描述】:

我想显示 Observable Array 中的文本,但它总是显示 [object Object]。

我尝试从 https://docs.nativescript.org/vuejs/ns-ui/ListView/getting-started 复制和粘贴示例,但它仍然显示 [object Object]

这是我的代码,类似于上面 URL 中的示例:

<template>
  <page>
      <StackLayout>
        <RadListView ref="listView" for="item in itemList" height="50%">
          <v-template>  
           <StackLayout>
              <Label :text="item.name"/>
           <StackLayout>
         </v-template>
        </RadListView>
    </StackLayout>
  </page>
</template>

<script>
 import { ObservableArray } from 'tns-core-modules/data/observable-array';
  export default {
    data() {
      return {
         itemList: new ObservableArray([
        {name: 'Item 1', description: 'Item 1 description'},
        {name: 'Item 2', description: 'Item 2 description'},
        {name: 'Item 3', description: 'Item 3 description'},
        ]),
      };
    },


    methods: {


    }
  };

</script>

我希望标签显示 Observable Array 值

【问题讨论】:

  • 我无法重现这个问题,你能分享一个 Playground 示例吗?
  • 这里是网址https://play.nativescript.org/?template=play-vue&amp;id=beIZRg&amp;v=1@Manoj

标签: android vue.js nativescript


【解决方案1】:

RadListView 对 Vue 有开箱即用的支持,你假设不是注册元素而是使用 Vue 插件。

import RadListView from 'nativescript-ui-listview/vue';
Vue.use(RadListView);

Updated Playground

【讨论】:

    猜你喜欢
    • 2019-07-06
    • 2021-08-04
    • 2019-11-05
    • 2017-04-23
    • 2019-06-13
    • 1970-01-01
    • 1970-01-01
    • 2023-02-25
    • 2020-05-13
    相关资源
    最近更新 更多