File tree Expand file tree Collapse file tree 1 file changed +10
-4
lines changed
examples/sites/src/views/components Expand file tree Collapse file tree 1 file changed +10
-4
lines changed Original file line number Diff line number Diff line change @@ -451,7 +451,7 @@ export default defineComponent({
451451 })
452452 }
453453 }
454- }, 600 )
454+ }, 0 )
455455 }
456456
457457 // 在singleDemo情况时,才需要滚动示例区域到顶
@@ -557,7 +557,12 @@ export default defineComponent({
557557 }
558558
559559 // F5刷新加载时,跳到当前示例
560- scrollByHash(hash)
560+ // 应当在所有demo渲染完毕后在滚动,否则滚动完位置后,demo渲染会使滚动位置错位
561+ setTimeout(() => {
562+ nextTick(() => {
563+ scrollByHash(hash)
564+ })
565+ }, 0)
561566 })
562567 .finally(() => {
563568 // 获取组件贡献者
@@ -645,11 +650,12 @@ export default defineComponent({
645650 router.push(data.link)
646651 } else if (apiModeState.demoMode === 'default' && data.link.startsWith('#')) {
647652 // 多示例模式,自动会切到相应的位置。只需要记录singleDemo就好了
653+ e.preventDefault()
648654 const hash = data.link.slice(1)
649655 state.currDemoId = hash
650656 state.singleDemo = state.currJson.demos.find((d) => d.demoId === hash)
651-
652- e.preventDefault( )
657+ router.push(data.link)
658+ scrollByHash(hash )
653659 }
654660 }
655661 }
You can’t perform that action at this time.
0 commit comments