NativeScript错误.在列表模板中找到多个视图 [英] NativeScript error. More than one view found in list template

查看:45
本文介绍了NativeScript错误.在列表模板中找到多个视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的ListView

I had such ListView

<ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
    <template let-item="item" columns="*, auto" >
      <Label [text]="item.name" class="medium-spacing"></Label>      
    </template>
  </ListView>

我要添加图像按钮.所以我只是将columns="*, auto"添加到templatecol="0"标记和col="1"到我的Image

I want to add image button. So I just added columns="*, auto" to template and col="0" to Label and col="1" to my Image

 <ListView [items]="groceryList" row="1" class="small-spacing" [class.visible]="listLoaded">
    <template let-item="item" columns="*, auto" >
      <Label [text]="item.name" class="medium-spacing" col="0"></Label>
      <Image src="res://delete" (tap)="delete(item.id)" col="1"></Image>      
    </template>
  </ListView>

运行模拟器后,出现错误:

After running an emulator I am getting an error:

有人在想为什么会发生这种情况以及如何解决?

Any thoughts why is that happening and how to fix that?

推荐答案

<template>内仅允许一个元素,而您有两个. 而是在<template>内部添加单个GridLayout,然后在其中添加元素.

Only one element allowed innside <template>, you have two. Add a single GridLayout innside the <template> instead, then add you elements there.

这篇关于NativeScript错误.在列表模板中找到多个视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆