Skip to content

Commit

Permalink
fix(anchor): [anchor] fix anchor error when links is empty (#2155)
Browse files Browse the repository at this point in the history
* fix(anchor): [anchor] fix anchor error when links is empty

* fix(anchor): [anchor] fix anchor error when links is empty
  • Loading branch information
gimmyhehe authored Sep 20, 2024
1 parent ce35aef commit 1d6b6bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/renderless/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@opentiny/vue-renderless",
"version": "3.18.2",
"version": "3.18.3",
"private": true,
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
"author": "OpenTiny Team",
Expand Down
3 changes: 3 additions & 0 deletions packages/renderless/src/anchor/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,9 @@ export const handleScroll = (state: IAnchorRenderlessParams['state']) => () => {

// 设置滚动偏移量
const setChildOffsetTop = ({ state, props }: Pick<IAnchorRenderlessParams, 'state' | 'props'>) => {
if (!props.links?.length) {
return
}
state.offsetTop = document.querySelector(props.links[0].link)?.offsetTop || 0
}

Expand Down

0 comments on commit 1d6b6bd

Please sign in to comment.