Skip to content

ScrollList Horizontal Scrolling List Component ​

This component is generally used for scenarios where multiple products or categories are displayed simultaneously, and it can also implement a list that swipes left and right.

📌 Platform Difference Notes ​

APP(vue)H5WeChat Mini ProgramAlipay Mini Program
✔✔✔✔

🏯 Basic Usage Example ​

html
<!-- Global usage -->
<hy-scroll-list>
    <view v-for="(item, index) in list" :key="index">
        <image :src="item"></image>
    </view>
</hy-scroll-list>
ts
const list = ref<any[]>([
    'https://img0.baidu.com/it/u=1913990970,584854398&fm=253&id=1',
    'http://mms2.baidu.com/it/u=204741874,3444396868&fm=253&id=2',
    'https://img2.baidu.com/it/u=3042825715,659259329&fm=253&id=3',
    'https://img2.baidu.com/it/u=109690972,2214958998&fm=253&id=4',
    'http://mms0.baidu.com/it/u=2161107790,808970254&fm=253&id=5',
    'https://img2.baidu.com/it/u=4211554685,400408647&fm=253&id=6',
    'https://img2.baidu.com/it/u=2237681987,1998118702&fm=253&id=7',
    'https://img1.baidu.com/it/u=2494879897,1602792615&fm=253&id=8',
]);

Business Implementation Code ​

html
<up-scroll-list @right="right" @left="left">
    <view class="scroll-list" style="flex-direction: row;">
        <view
            class="scroll-list__goods-item"
            v-for="(item, index) in list"
            :key="index"
            :class="[(index === 9) && 'scroll-list__goods-item--no-margin-right']"
        >
            <image class="scroll-list__goods-item__image" :src="item.thumb"></image>
            <text class="scroll-list__goods-item__text">¥{{ item.price }}</text>
        </view>
        <view class="scroll-list__show-more">
            <text class="scroll-list__show-more__text">View More</text>
            <up-icon name="arrow-leftward" color="#f56c6c" size="12"></up-icon>
        </view>
    </view>
</up-scroll-list>
ts
import { ref } from 'vue';

const goodsArr = [
    {
        price: '230.5',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '74.1',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '8457',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '1442',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '541',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '234',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '562',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
    {
        price: '251.5',
        thumbnail:
            'https://img11.360buyimg.com/n1/s450x450_jfs/t1/281169/10/14028/31748/67ecf51dF384c5bd6/1ec0c214ea7a914e.png',
    },
];

// Methods
const left = () => {
    console.log('left');
};

const right = () => {
    console.log('right');
};

const showMore = () => {
    uni.showToast({ title: 'View More' });
};
scss
.scroll-list {
    display: flex;
    flex-direction: column;

    &__goods-item {
        margin-right: 20px;

        &__image {
            width: 60px;
            height: 60px;
            border-radius: 4px;
        }

        &__text {
            color: #f56c6c;
            text-align: center;
            font-size: 12px;
            margin-top: 5px;
        }
    }

    &__show-more {
        background-color: #fff0f0;
        border-radius: 3px;
        padding: 3px 6px;
        display: flex;
        flex-direction: column;
        align-items: center;

        &__text {
            font-size: 12px;
            width: 12px;
            color: #f56c6c;
            line-height: 16px;
        }
    }
}

API ​

ScrollList Props ​

ParameterDescriptionTypeDefault
indicatorWidthOverall width of the indicator; default unit is pxnumber50
indicatorBarWidthWidth of the slider bar; default unit is pxnumber20
indicatorWhether to show the panel indicatorbooleantrue
indicatorColorInactive color of the indicatorstring-
indicatorActiveColorColor of the indicator slider barstring-
indicatorStyleIndicator style; can be positioned via bottom, left, rightCSSProperties-

Events ​

Event NameDescriptionCallback Parameters
scrollLeftTriggered when scrolled to the left-
scrollRightTriggered when scrolled to the right-

Slots ​

Slot NameDescriptionAccepted Values
default--

CSS Variables ​

Variable NameDescriptionDefault Value
--hy-scroll-list-indicator-widthIndicator width60px
--hy-scroll-list-indicator-heightIndicator height4px
--hy-scroll-list-indicator-bar-widthIndicator slider bar width20px
--hy-scroll-list-indicator-radiusIndicator border radiusFollows --hy-radius-semicircle (100px)
12:33
battery