Skip to content
This repository was archived by the owner on Dec 6, 2021. It is now read-only.
This repository was archived by the owner on Dec 6, 2021. It is now read-only.

VirtualScroll :itemHeight 单位固定成为了px,无法适配小程序 #108

@dengs-official

Description

@dengs-official

问题描述

使用 VirtualScroll 组件生成虚拟列表时,设置了 itemHeight 属性后,计算生成的容器总高度和子项偏移高度单位都为px,不会自动转换

版本信息

1.0.0-alpha.21

涉及的平台

weapp

错误信息

// error message here
image

代码

小程序用以下方式修复后可以设置正确当前页和子项的高度,在内联样式中将高度转换为了对应的px,
但是在滚动时计算会出错,应该是获取到的scrollTop值有误

// packages/virtual-scroll/index.ts

// line-116
const top = convertToUnit(index * __itemHeight.value, 'rpx');

// line-154
height: convertToUnit((props.items.length * __itemHeight.value), 'rpx'),

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions