nativescript-fancy-list-view
by triniwiz | v0.0.9
时尚列表视图
npm i --save nativescript-fancy-list-view

npm npm Build Status

NativeScript FancyListView 🍵

安装

tns plugin add nativescript-fancy-list-view

使用方法

重要:确保在页面元素中包含 xmlns:lv="nativescript-fancy-list-view",任何元素都可以用于列表

<lv:FancyListView items="{{items}}" row="2" id="listView">
<lv:FancyListView.itemTemplate>
<GridLayout rows="auto, *" columns="*" backgroundColor="red">
<Label text="{{title}}"/>
<Image row="1" src="{{image}}"/>
</GridLayout>
</lv:FancyListView.itemTemplate>
</lv:FancyListView>

多模板

<lv:FancyListView itemTemplateSelector="$index % 2 === 0 ? 'even' : 'odd'" items="{{items}}" id="listView">
<FancyListView.itemTemplates>
<template key="even">
<GridLayout rows="auto,auto,*" columns="*">
<Label text="Even"/>
<Label row="1" text="{{title}}"/>
<Image loaded="loadedImage" row="2" src="{{image}}"/>
</GridLayout>
</template>
<template key="odd">
<GridLayout rows="auto,auto ,auto,*" columns="*" backgroundColor="white">
<Label text="Odd"/>
<Label row="1" text="{{title}}"/>
<StackLayout row="2">
<Label text="{{image}}"/>
</StackLayout>
<Image loaded="loadedImage" row="3" src="{{image}}"/>
</GridLayout>
</template>
</FancyListView.itemTemplates>
</lv:FancyListView>

Angular

import { FancyListViewModule } from "nativescript-fancy-list-view/angular";

@NgModule({
imports: [
FancyListViewModule
],
declarations: [
AppComponent
],
bootstrap: [AppComponent]
})

Angular v2

<FancyListView [items]="items" #listview (itemTap)="onTap($event)" class="listview">
<template let-i="index" let-item="item">
<GridLayout class="list-item" rows="auto, *" columns="*" backgroundColor="red">
<Label [text]="item.title"></Label>
<Image row="1" [src]="item.image"></Image>
</GridLayout>
</template>
</FancyListView>

Angular v4+

<FancyListView [items]="items" #listView (itemTap)="onTap($event)" class="listview">
<ng-template let-i="index" let-item="item">
<GridLayout class="list-item" rows="auto, *" columns="*" backgroundColor="red">
<Label [text]="item.title"></Label>
<Image row="1" [src]="item.image"></Image>
</GridLayout>
</ng-template>
</FancyListView>

多模板

 public templateSelector = (item: any, index: number, items: any) => {
return index % 2 === 0 ? 'even' : 'odd';
}
<FancyListView [items]="items | async" [itemTemplateSelector]="templateSelector"  #listView (itemTap)="onTap($event)" class="listview">
<ng-template flvTemplateKey="even" let-i="index" let-item="item">
<GridLayout class="list-item" rows="auto,auto,*" columns="*">
<Label text="Even"></Label>
<Label row="1" [text]="item.title"></Label>
<Image loaded="loadedImage" row="2" [src]="item.image"></Image>
</GridLayout>
</ng-template>

<ng-template flvTemplateKey="odd" let-i="index" let-item="item">
<GridLayout class="list-item" rows="auto,auto,auto,*" columns="*" backgroundColor="white">
<Label text="Odd"></Label>
<Label row="1" [text]="item.title"></Label>
<StackLayout row="2">
<Label [text]="item.image"></Label>
</StackLayout>
<Image loaded="loadedImage" row="3" [src]="item.image" ></Image>
</GridLayout>
</ng-template>

</FancyListView>

配置

<FancyListView items="{{items}}" itemWidth="25%" itemHeight="50%" max="75%" min="20%" spanCount="2" layoutType="grid"><FancyListView>

属性

属性 默认值 类型 必需 描述
items null 数组
  • - [x]
itemWidth 100% 字符串 / 数字
  • - [ ]
itemHeight 25% 字符串 / 数字
  • - [ ]
min (itemWidth * 2) / (1/3) 字符串 / 数字
  • - [ ]
max (itemWidth * 2) 字符串 / 数字
  • - [ ]
spanCount 1 数字
  • - [ ]
layoutType 线性 字符串
  • - [ ]
iOS Android
即将推出!! 即将推出!!