问题
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