List

List.

List

Attribute NameDescriptionTypeDefault
classNameCustom classString

Slots

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

List-item

AttributeDescriptionTypeDefault
classNameCustom classString
thumbThumbnail, picture addressString
arrowWith arrow or notBooleanfalse
alignVertical alignment of sub-elements, choices: top,middle,bottomStringmiddle
indexUnique index of list itemString
onClickCall this function when   clicking list-item({index, target}) =>   void
lastIf it is the last list itemBooleanfalse
disabledNot clickable, no hover   effectBooleanfalse
multipleLineMultiple linesBooleanfalse
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`,
    });
  },
});