首页 文章

Nativescript:错误:在列表模板中找到多个视图!嵌套级别:0

提问于
浏览
1

The layout inside template solution doesn't work

list.html

<ActionBar title="View Team Members">
    <NavigationButton text="Back" android.systemIcon="ic_menu_back"></NavigationButton>
</ActionBar>
<GridLayout>
    <ListView [items]="teamList" class="small-spacing">
        <template let-item="item">
            <StackLayout>
              <Label [text]="item.name" class="medium-spacing"></Label>
              <Label [text]="item.email" class="medium-spacing"></Label>
            </StackLayout>
        </template>
    </ListView>
</GridLayout>

相同的错误跟踪:

com.tns.NativeScriptException:
调用js方法getView失败

错误:在列表模板中找到多个视图!嵌套级别:0
文件:“/ data / data / target.nativescript.finlyng / files / app / tns_modules / numscript-angular / difiress / list-view-comp.js,
line:138,column:8 StackTrace:
框架:function:'getSingleViewRecursive',file:'/ data / data / org.nativescript.finlyng / files / app / tns_modules / nativescript-angular / directives / list-view-comp.js',
line:138,column:15 Frame:function:'getSingleViewFromViewRef',file:'/ data / data / org.nativescript.finlyng / files / app / tns_modules / nativescript-angular / directives / list-view-comp.js', line:154,column:12 Frame:function:'ListViewComponent.onItemLoading',file:'/ data / data / org.nativescript.finlyng / files / app / tns_modules / nativescript-angular / directives / list-view-comp.js ',line:72,column:25 Frame:function:'Observable.notify',file:'/ data / data / org.nativescript.finlyng / files / app / tns_modules / data / observable / observable.js',line: 146,column:32 Frame:function:'ListViewAdap

1 回答

  • 1

    这已经很老了,但我遇到了类似的问题 .

    我通过在GridLayout中嵌套标签来修复它 . 在我的情况下这样的事情:

    <GridLayout rows="auto, *">
      <ListView [items]="newsList" row="1" class="news">
        <ng-template let-item="item">
          <GridLayout rows="auto, *">
            <Image [src]="item.image"></Image>
            <Label [text]="item.title" class="news__item"></Label>
          </GridLayout>
        </ng-template>
      </ListView>
    </GridLayout>
    

相关问题