TNS v2.5.0
我已将 LISTVIEW_DIRECTIVES
导入到我的app.module中,我的模板看起来像
<ActionBar title="Events"></ActionBar>
<StackLayout orientation="vertical">
<RadListView [items]="events">
<template tkListItemTemplate let-event="item">
<StackLayout orientation="vertical">
<Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
<Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
</StackLayout>
</template>
</RadListView>
</StackLayout>
但这显示什么,但改为常规 ListView
工作正常 .
如果我尝试 GridLayout
就好
<ActionBar title="Events"></ActionBar>
<GridLayout>
<RadListView [items]="events">
<template tkListItemTemplate let-event="item">
<StackLayout orientation="vertical">
<Image [src]="'https:' + event.image" stretch="aspectFit"></Image>
<Label [nsRouterLink]="['/event', event.id]" [text]="event.title"></Label>
</StackLayout>
</template>
</RadListView>
</GridLayout>
该应用程序因错误而崩溃
file:///app/tns_modules/nativescript-telerik-ui/listview/listview.js:1034:104:JS ERROR TypeError:undefined不是对象(评估'itemViewDimensions.measuredWidth')2月5日11:40:53 Marcuss-iMac com.apple.CoreSimulator.SimDevice.1A8C1E25-DAC0-4BA0-822E-5A6F731F1CD7.launchd_sim [31919](UIKitApplication:org.nativescript.t4g [0x7b2a] [36194]):由于分段故障退出服务:11
不确定我是否错过了在某处导入的东西,但文档非常粗略,因此很难确定并查看示例
5 回答
LISTVIEW_DIRECTIVES用于使用Javascript的Nativescript .
对于Angular2:
安装插件 tns plugin add nativescript-telerik-ui 之后 rebuild 与tns运行android以获得新的插件工作 .
在 module.ts 添加:
import from "nativescript-telerik-ui/listview/angular";
并在同一个文件中:
在@NgModule imports 添加: NativeScriptUIListViewModule,
它会准备好的 .
以下是我如何使用它 .
应用程序/共享/共享directives.module.ts
这是一个例子 .
应用程序/事件/ events.module.ts
应用程序/事件/ events.component.html
我需要'm not sure it',但我在项目中有
RadListView
并且ListViewLinearLayout
作为其子项之一:你也在你的app模块中将
LISTVIEW_DIRECTIVES
添加到declarations
列表中了吗?我遇到了同样的问题 . 我在app模块中导入并声明了LISTVIEW_DIRECTIVES . 包含ListView的组件在子模块中声明 . 当我将LISTVIEW_DIRECTIVES的decalaration移动到子模块时,错误就消失了 .
你需要设置列表的高度,默认情况下高度为0px;