# list-builder

> 基础库 3.3.0 开始支持，低版本需做[兼容处理](/miniprogram/dev/framework/compatibility.md)。

> 相关文档: [Skyline 渲染引擎](/miniprogram/dev/framework/runtime/skyline/introduction.md)、[Skyline 迁移起步](/miniprogram/dev/framework/custom-component/glass-easel/migration.md)

渲染框架支持情况：Skyline （使用最新 [Nightly](/miniprogram/dev/devtools/nightly.html) 工具调试）

## 功能描述

列表构造器，仅支持作为 `<scroll-view type="custom">` 模式的直接子节点。具体用法可参考 [scroll-view](./scroll-view#列表构造器使用方法)

## 通用属性


```json
[
  {
    "属性": "padding",
    "类型": "Array",
    "默认值": "[0, 0, 0, 0]",
    "必填": "否",
    "说明": "长度为 4 的数组，按 top、right、bottom、left 顺序指定内边距",
    "最低版本": ""
  },
  {
    "属性": "type",
    "类型": "string",
    "默认值": "static",
    "必填": "是",
    "说明": "类型，默认为定高模式",
    "最低版本": "",
    "子项": [
      {
        "合法值": "static",
        "说明": "定高模式，所有列表项等高，需要传入 child-height"
      },
      {
        "合法值": "dynamic",
        "说明": "不定高模式"
      }
    ]
  },
  {
    "属性": "list",
    "类型": "Array",
    "默认值": "",
    "必填": "是",
    "说明": "需要用于渲染的列表",
    "最低版本": ""
  },
  {
    "属性": "child-count",
    "类型": "Array",
    "默认值": "",
    "必填": "否",
    "说明": "完整列表的长度，如果不传则取 list 的长度作为其值",
    "最低版本": ""
  },
  {
    "属性": "child-height",
    "类型": "Array",
    "默认值": "",
    "必填": "否",
    "说明": "列表项的高度，当 type 为 static 时必须传入",
    "最低版本": ""
  },
  {
    "属性": "bind:itembuild",
    "类型": "eventhandle",
    "默认值": "",
    "必填": "否",
    "说明": "列表项创建时触发，event.detail = {index}，index 即被创建的列表项序号",
    "最低版本": ""
  },
  {
    "属性": "bind:itemdispose",
    "类型": "eventhandle",
    "默认值": "",
    "必填": "否",
    "说明": "列表项回收时触发，event.detail = {index}，index 即被回收的列表项序号",
    "最低版本": ""
  },
  {
    "属性": "initial-child-count",
    "类型": "number",
    "默认值": "0",
    "必填": "否",
    "说明": "首次渲染时渲染的列表项数量，用于减少首次渲染时的白屏时长。不传则首屏也根据布局结果按需渲染",
    "最低版本": "[3.7.12](/miniprogram/dev/framework/compatibility.md)"
  }
]
```

## Bug & Tip

1. `tip`: 目前只支持纵向滚动列表

## 使用方法

```html
<scroll-view
  type="custom"
  scroll-y
>
   <list-builder
    list="{{list}}"
    child-count="{{list.length}}"
    child-height="200"
  >
    <view slot:item slot:index style="height: 200px;">
      <view>{{item.id}}-{{index}}</view>
    </view>
  </list-builder>
</scroll-view>
```
