Skip to content
官方QQ交流群
pc端ui:468705115   点此加入
移动端ui:468217742   点此加入
技术交流1:87208295   点此加入
技术交流2:787747122   点此加入
官网
云控制台
开放平台
关注微信公众号
代码仓库: 码云

List 列表

该组件为高性能列表组件

平台差异说明

App(vue)App(nvue)H5小程序

基本使用

  • 配合组件u-list-item嵌套使用
  • 参数show-scrollbar是否出现滚动条仅在 nvue 中有效
  • 事件@scrolltolower滚动到底部触发事件
html
<template>
  <view class="u-page">
    <up-list @scrolltolower="scrolltolower">
      <up-list-item v-for="(item, index) in indexList" :key="index">
        <up-cell :title="`列表长度-${index + 1}`">
          <up-avatar
            slot="icon"
            shape="square"
            size="35"
            :src="item.url"
            customStyle="margin: -3px 5px -3px 0"
          ></up-avatar>
        </up-cell>
      </up-list-item>
    </up-list>
  </view>
</template>

<script>
  export default {
    data() {
      return {
        indexList: [],
        urls: [
          "https://xxx.com/album/1.jpg",
          "https://xxx.com/album/2.jpg",
          "https://xxx.com/album/3.jpg",
          "https://xxx.com/album/4.jpg",
          "https://xxx.com/album/5.jpg",
          "https://xxx.com/album/6.jpg",
          "https://xxx.com/album/7.jpg",
          "https://xxx.com/album/8.jpg",
          "https://xxx.com/album/9.jpg",
          "https://xxx.com/album/10.jpg",
        ],
      };
    },
    onLoad() {
      this.loadmore();
    },
    methods: {
      scrolltolower() {
        this.loadmore();
      },
      loadmore() {
        for (let i = 0; i < 30; i++) {
          this.indexList.push({
            url: this.urls[uni.$up.random(0, this.urls.length - 1)],
          });
        }
      },
    },
  };
</script>

此页面源代码地址

页面源码地址


 github  gitee

API

List Props

参数说明类型默认值可选值
showScrollbar控制是否出现滚动条,仅 nvue 有效Booleanfalsetrue
lowerThreshold距底部多少时触发 scrolltolower 事件String/Number50-
upperThreshold距顶部多少时触发 scrolltoupper 事件,非 nvue 有效String/Number0-
scrollTop设置竖向滚动条位置String/Number0-
offsetAccuracy控制 onscroll 事件触发的频率,仅 nvue 有效String/Number10-
enableFlex启用 flexbox 布局。开启后,当前节点声明了 display: flex 就会成为 flex container,并作用于其孩子节点,仅微信小程序有效Booleanfalse-
pagingEnabled是否按分页模式显示 List,默认值 falseBooleanfalse-
scrollable是否允许 List 滚动Booleantrue-
scrollIntoView值应为某子元素 id(id 不能以数字开头)String--
scrollWithAnimation在设置滚动条位置时使用动画过渡Booleanfalse-
enableBackToTopiOS 点击顶部状态栏、安卓双击标题栏时,滚动条返回顶部,只对微信小程序有效Booleanfalse-
height列表的高度String/Number0-
width列表宽度String/Number0-
preLoadScreen列表前后预渲染的屏数,1 代表一个屏幕的高度,1.5 代表 1 个半屏幕高度String/Number1-

List Events

事件名说明回调参数
scroll滚动条滚动触发事件scrollTop: 滚动条位置
scrolltolower滚动到底部触发事件-

ListItem Props

参数说明类型默认值可选值
anchor用于滚动到指定 itemString/Number--

Copyright © 2017 10yun.com | 十云提供计算服务-IPV6 | ctocode组开发