Skip to content

Commit 1d6b6bd

Browse files
authored
fix(anchor): [anchor] fix anchor error when links is empty (#2155)
* fix(anchor): [anchor] fix anchor error when links is empty * fix(anchor): [anchor] fix anchor error when links is empty
1 parent ce35aef commit 1d6b6bd

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

packages/renderless/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@opentiny/vue-renderless",
3-
"version": "3.18.2",
3+
"version": "3.18.3",
44
"private": true,
55
"description": "An enterprise-class UI component library, support both Vue.js 2 and Vue.js 3, as well as PC and mobile.",
66
"author": "OpenTiny Team",

packages/renderless/src/anchor/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,9 @@ export const handleScroll = (state: IAnchorRenderlessParams['state']) => () => {
124124

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

0 commit comments

Comments
 (0)