fix(BackTop): failed to get element ref (#11269)

This commit is contained in:
neverland 2022-11-19 11:14:03 +08:00 committed by GitHub
parent 5cf4322143
commit 5bbdb0f40c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -95,11 +95,10 @@ export default defineComponent({
onMounted(() => {
nextTick(() => {
if (inBrowser) {
scrollParent.value = document.documentElement;
target = props.target
? (getTarget() as typeof target)
: (getScrollParent(backTopEl.value!) as typeof target);
scrollParent.value = target as typeof target;
scrollParent.value = target;
}
});
});
@ -107,7 +106,7 @@ export default defineComponent({
return () => {
const Content = (
<div
ref="backTopEl"
ref={backTopEl}
class={bem({ active: show.value })}
style={backTopStyle.value}
onClick={onClick}