List

List

List

Property

DescriptionType
classNameCustom class.String

Slots

slotNameDescription
headerOptional, list header.
footerOptional, used to render list footer.

List-item

Property

DescriptionTypeDefault
classNameCustom class. String
thumbThumbnail, picture address.String
arrowWith arrow or not.Booleanfalse
alignVertical alignment of sub-elements, choices: top,middle,bottomStringmiddle
indexUnique index of list item.String
onClickCall this function when clicking list-item.({index, target}) => void
lastIf it is the last list item.Booleanfalse
disabledNot clickable, no hover effect.Booleanfalse
multipleLineMultiple lines.Booleanfalse
wrapWrap or not. By default,   excessive text length is hidden.Booleanfalse

Slots

slotnameDescription
extraOptional, used to render right-hand notes of list item. 
prefixOptional, used to render left-hand notes of list item.

Example

copy
{
  "defaultTitle": "AntUI Component Library",
  "usingComponents": {
    "list": "mini-antui/es/list/index",
    "list-item": "mini-antui/es/list/list-item/index"
  }
}
copy
<view>
  <list>
    <view slot="header">
      List Header
    </view>
    <block a:for="{{items}}">
      <list-item
        thumb="{{item.thumb}}"
        arrow="{{item.arrow}}"
        align="{{item.align}}"
        index="{{index}}"
        onClick="onItemClick"
        key="items-{{index}}"
        last="{{index === (items.length - 1)}}"
      >
      {{item.title}}
        <view class="am-list-brief">{{item.brief}}</view>
        <view slot="extra">
          {{item.extra}}
        </view>
      </list-item>
    </block>
    <view slot="footer">
      List footer
    </view>
  </list>
  <list>
    <view slot="header">
      List Header
    </view>
    <block a:for="{{items2}}">
      <list-item
        thumb="{{item.thumb}}"
        arrow="{{item.arrow}}"
        onClick="onItemClick"
        index="items2-{{index}}"
        key="items2-{{index}}"
        last="{{index === (items2.length - 1)}}"
      >
       {{item.title}}
        <view class="am-list-brief">{{item.brief}}</view>
        <view a:if="{{item.extra}}" slot="extra">
          {{item.extra}}
        </view>
      </list-item>
    </block>
    <view slot="footer">
      List footer
    </view>
  </list>
</view>
copy
Page({
  data: {
    items: [
      {
        title: 'Simple List',
        extra: 'Details',
      },
    ],
    items2: [
      {
        title: 'Complex List',
        arrow: true,
      },
      {
        title: 'Complex List',
        arrow: 'up',
      },
      {
        title: 'Complex List',
        arrow: 'down',
      },
      {
        title: 'Complex List',
        arrow: 'empty',
      },
      {
        title: 'Complex List',
      },
    ],
  },
  onItemClick(ev) {
    my.alert({
      content: `Click the ${ev.index} row`,
    });
  },
});