NativeScript 错误.在列表模板中找到多个视图 [英] NativeScript error. More than one view found in list template
本文介绍了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"
添加到 template
和col="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?
推荐答案
中只允许一个元素,你有两个.在
内部添加单个 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屋!
查看全文