Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Anchor 锚点,在子项高度不同时,出现指向异常 #4711

Open
lgwwwww opened this issue Nov 4, 2024 · 2 comments
Open

Anchor 锚点,在子项高度不同时,出现指向异常 #4711

lgwwwww opened this issue Nov 4, 2024 · 2 comments

Comments

@lgwwwww
Copy link

lgwwwww commented Nov 4, 2024

tdesign-vue-next 版本

1.10.1

重现链接

No response

重现步骤

文档里的例子

anchor-content-1
anchor-content-2
anchor-content-3
anchor-content-4
anchor-content-5
<script setup> import { computed, getCurrentInstance } from 'vue'; import get from 'lodash/get';

const { appContext } = getCurrentInstance();
const path = computed(() => get(appContext, '$route.path', ''));

const handleClick = ({ e, href, title }) => {
e.preventDefault();
console.log('click', href, title);
};
</script>

<style lang="less" scoped> .anchor-container-demo { display: flex; height: 300px; } #anchor-container { flex-grow: 1; overflow: auto; div { text-align: center; font-size: 22px; line-height: 100px; } .anchor-content-1 { background: #ecf2fe; height: 100px; } .anchor-content-2 { background: #d4e3fc; height: 800px; } .anchor-content-3 { background: #bbd3fb; height: 230px; } .anchor-content-4 { background: #96bbf8; height: 333px; } .anchor-content-5 { background: #699ef5; height: 90px; } } </style>

期望结果

在每个盒子的高度都不时,出现点击后锚点能正确跳转到指定项

实际结果

跳转的锚点不正确,会出现位置能准确跳转,但锚点指示不正确。但是如果设置了targetOffset属性就正常了,
源码中未设置时

image

设置了targetOffset之后:
image

框架版本

No response

浏览器版本

No response

系统版本

No response

Node版本

No response

补充说明

No response

Copy link
Contributor

github-actions bot commented Nov 4, 2024

👋 @lgwwwww,感谢给 TDesign 提出了 issue。
请根据 issue 模版确保背景信息的完善,我们将调查并尽快回复你。

@lgwwwww
Copy link
Author

lgwwwww commented Nov 4, 2024

文档中的 指定容器锚点 的例子,给每项设置不同高度是出现的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant