NativeScript error. More than one view found in list template

落爺英雄遲暮 提交于 2019-12-11 03:53:49

问题


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>

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?


回答1:


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



来源:https://stackoverflow.com/questions/40241716/nativescript-error-more-than-one-view-found-in-list-template

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!