v2版本的DatePicker日期选择组件选中区域高度在某些机型上的高度bug及解决方案 #5233
Answered
by
damonyoungcc
damonyoungcc
asked this question in
Q&A
-
Beta Was this translation helpful? Give feedback.
Answered by
damonyoungcc
May 25, 2022
Replies: 3 comments 2 replies
-
要不转成 discussion 吧?issue close 了就不好找到了 😵 |
Beta Was this translation helpful? Give feedback.
0 replies
-
原因分析初步分析,原因是 然后往上追溯源码,发现v2的日期组件最终依赖 -> rmc-picker 查看源码后,发现 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% ${itemHeight * num}px`; 经过验证发现, |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
awmleer
-
好的 |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
原因分析
初步分析,原因是
am-picker-col-mask
的backgroundSize
的高度出现错误导致,如下图然后往上追溯源码,发现v2的日期组件最终依赖 -> rmc-picker
查看源码后,发现
backgroundSize
行内样式高度的设置代码,在这里 第178行,下面是源码