提交 9b1dd076 编写于 作者: D DCloud_LXH

fix: pageScrollTo selector question/109566

上级 9c626ab8
export const pageScrollTo = {
scrollTop: {
type: Number,
required: true
type: Number
},
duration: {
type: Number,
......@@ -10,4 +9,4 @@ export const pageScrollTo = {
params.duration = Math.max(0, duration)
}
}
}
}
......@@ -8,8 +8,19 @@ export function disableScroll (evt) {
export function pageScrollTo ({
scrollTop,
selector,
duration
}) {
if (typeof scrollTop === 'undefined') {
const el = document.querySelector(selector)
if (el) {
const { top, height } = el.getBoundingClientRect()
scrollTop = top + window.pageYOffset
if (__PLATFORM__ === 'h5') {
scrollTop -= height
}
}
}
const documentElement = document.documentElement
const {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册