Skip to content

v2版本的DatePicker日期选择组件选中区域高度在某些机型上的高度bug及解决方案 #5233

Answered by damonyoungcc
damonyoungcc asked this question in Q&A
Discussion options

You must be logged in to vote

原因分析

初步分析,原因是am-picker-col-maskbackgroundSize的高度出现错误导致,如下图

然后往上追溯源码,发现v2的日期组件最终依赖 -> rmc-picker

查看源码后,发现backgroundSize行内样式高度的设置代码,在这里 第178行,下面是源码

    const { contentRef, indicatorRef, maskRef, rootRef } = this;
    const rootHeight = rootRef.getBoundingClientRect().height;
    // https://github.com/react-component/m-picker/issues/18
    const itemHeight = this.itemHeight = indicatorRef.getBoundingClientRect().height;
    let num = Math.floor(rootHeight / itemHeight);
    if (num % 2 === 0) {
      num--;
    }
    num--;
    num /= 2;
    contentRef.style.padding = `${itemHeight * num}px 0`;
    indicatorRef.style.top = `${itemHeight * num}px`;
    maskRef.style.backgroundSize = `100% ${i…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

damonyoungcc
May 25, 2022
Collaborator Author

You must be logged in to vote
0 replies
Answer selected by awmleer
Comment options

damonyoungcc
May 25, 2022
Collaborator Author

You must be logged in to vote
2 replies
@awmleer
Comment options

@damonyoungcc
Comment options

damonyoungcc May 25, 2022
Collaborator Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #5232 on May 25, 2022 03:31.